Those four phases have separate offside lines, so this article is only really concerned with open play.
In this situation, a player is offside if he is in front of a team mate either carrying the ball, or who last played it.
He must not interfere by going at the ball, tackling the carrier or preventing the opposition from playing with the ball as they wish.
Such offside players can become legal again either by their own actions or those of team mates, and can be put on-side by certain actions of the opposition.
Offside players could either move behind a team mate who last played the ball, or simply move behind another onside team mate.
Onside team mates can also move past him, although notably if the onside teammate has run over the touchline, they have to re-enter the field of play to make them legal.
An interesting scenario which often happens is when a player goes back to retrieve a kicked ball but fails to gather it in.
Because he has played the ball, the others coming back from in front of him are now offside.
Those arriving therefore need to retire behind their team mate who last played the ball before they can go for it.
What often happens is the arriving player thinks he can go for the ball because he has retired behind where it was played at, but in actual fact he needs to retire behind where his team mate is now.
In open play, an offside player can be put on-side when an opponent runs 5m with the ball, passes it, or kicks it.
A fourth way is when an opponent touches the ball but can't gather it in, such as a knock on.
When a player kicks ahead, all team mates in front of him are offside – they must immediately stop moving forwards until they have been put on-side.
However, if they are within 10m of where the ball lands or is caught by an opponent, they must immediately retire back out to 10m from that point.
From a referee perspective, these are the players he needs to look out for, given they most likely to interfere with play illegally.
The natural inclination, especially for newer refs, is to look up at the ball after it has been kicked and therefore miss these offside players.
Once the ball is kicked, there is no need for refs to watch it in flight, as the laws of gravity will ensure it returns safely to earth.
Instead, the referee should be checking where the kicker's teammates were to identify which players are offside.
You can often hear him telling players to either hold their position or to retire out of the 10m area.
It is important to note that for players within that 10m area, no actions of the opponents will put them back onside.
What happens when the kick doesn't travel 10m, such as the halfback box kick, straight up at a lineout?
All the forwards are offside and within 10m of where the ball will land, so they have to retire backwards until they are 10m from where the ball lands.
In reality, they usually look up at the ball while standing still, while probably cursing the halfback when they are penalised.
There is one other offside scenario demanding total concentration from the referee, and that is when a kick is charged down by an opponent.
In this case, the 10m rule does not apply and things can happen very rapidly.
When a kick by a player from Team A is charged down by an opposition player, that puts all offside players from Team A back onside because Team B played the ball but has not gathered it.
But the players of Team B who were in front of their kick charger are not yet onside.
A lot of players think a charge-down puts everyone back onside, but those from the charging team are now in front of a team mate who last played the ball.
Players who know and understand the offside and onside rules can use this knowledge to their advantage.
I just wish more players had that knowledge and didn't complain when they are caught out.