The offside rule explained simply
Offside is the rule that confuses new supporters most, but the basic idea is simple: an attacker should not wait near the opponent's goal for a pass.
The basic rule
A player is in an offside position if, at the moment a teammate plays the ball to them, any part of their head, body or legs that can score a goal is closer to the opponent's goal line than both the ball and the second-last defender. The goalkeeper usually counts as one of the defenders, so in practice the question is whether the attacker is ahead of the last outfield defender.
Being in an offside position is not an offence
A player is only penalised if they take part in the play: playing the ball, interfering with an opponent or gaining an advantage from the position. Standing offside while the ball goes elsewhere is fine.
When a player cannot be offside
A player cannot be offside from a goal kick, a throw-in or a corner kick. A player also cannot be offside in their own half of the pitch, or when level with the second-last defender or with the last two defenders.
Offside and VAR
Video assistant referees check goals for offside using lines drawn on the replay. This is why a goal can be cancelled a minute after it was scored, and why live scores in apps sometimes drop by one. ScoreHub updates the score when the data provider does, so a goal that is ruled out will disappear shortly afterwards.