An attacking player MUST have two defenders between them and the goal, when the ball is served to them, in the opponent's half of the field or they are considered offside and an indirect free kick is awarded to the defending team.
If a player has one defender and the goalkeeper between them and the goal, then they are in an ONside position and may receive the ball. However, if the defender steps up in front of the attacking player BEFORE the ball is kicked to the attacker, then that attacker is in an OFFside position.
As shown below, the attacking player (white) on the right is in an offside position. If the ball is served, offside should be called.
The attacking player in the middle is in front of the ball, but is NOT in an offside position, as they are even with their defender (and the defender on the right is behind them).
NOTE: A player EVEN with the last field player (defender) is considered ONside.
NOTE: A player cannot be offside in their own half of the field.
NOTE: A player cannot be offside if the defensive team plays the ball to them.
NOTE: A player cannot be offside on a throw-in.
NOTE: A player cannot be offside on a goal kick.
NOTE: A player cannot be offisde on a corner kick.
There are many variations to the offside rule. For instance if the ball is kicked, an attacking player may run to an OFFside position to receive it. Below are some ONside examples.
The attacking players below are all ONside.
The attacking player ran to an offside position AFTER the ball was kicked, therefore they are considered ONside.