Overview
Offside is one of the laws in association football, codified in Law 11 of the Laws of the Game. The law states that a player is in an offside position if any of their body parts, except the hands and arms, are in the opponents' half of the pitch, and closer to the opponents' goal line than both the ball and the second-last opponent (the last opponent is usually, but not necessarily, the goalkeeper).
Being in an offside position is not an offence in itself, but a player so positioned when the ball is played by a teammate can be judged guilty of an offside offence if they receive the ball or will otherwise become "involved in active play", will "interfere with an opponent", or will "gain an advantage" by being in that position. Offside is often considered one of the most difficult-to-understand aspects of the sport.
Significance
Offside is judged at the moment the ball is last touched by the most recent teammate to touch the ball. Being in an offside position is not an offence in itself. A player who was in an offside position at the moment the ball was last touched or played by a teammate must then become involved in active play, in the opinion of the referee, in order for an offence to occur. When the offside offence occurs, the referee stops play, and awards an indirect free kick to the defending team from the place where the offending player became involved in active play.
The offside offence is neither a foul nor misconduct as it does not belong to Law 12. Like fouls, however, any play (such as the scoring of a goal) that occurs after an offence has taken place, but before the referee is able to stop the play, is nullified. The only time an offence related to offside is cautionable is if a defender deliberately leaves the field in order to deceive their opponents regarding a player's offside position, or if a forward, having left the field, returns and gains an advantage. In neither of these cases is the player penalised for being offside; instead they are cautioned for acts of unsporting behaviour.
From Wikipedia (CC BY-SA 4.0).