In rugby football, the offside rule prohibits players from gaining an advantage from being too far forward. The specifics of the rule differ between the two major codes.
Rugby union
Offside laws in rugby union are complex. However the basic principle is simple: a player may not derive any advantage from being in front of the ball. When the ball is carried by a single player in open play, any other player on the same team who is in front of the ball carrier is in an offside position. When the ball is in a ruck, maul, or line-out, any player who is in front of the hindmost foot of the hindmost player of the same side in the ruck/maul/scrum/lineout is in an offside position. When the ball is in a scrum, the scrum-half must remain behind the ball and all other players not in the scrum must remain behind a line parallel to the goal-line and five metres behind the hindmost foot. A player in an offside position is forbidden from interfering with play in any way. In particular, a player in an offside position
may not move towards, tackle or obstruct a player of the opposing team who has the ball, or who is waiting to receive the ball
must move at least 10 metresaway from any opponent who is waiting to receive the ball
Infringement of any of these rules is generally punished with a penalty awarded to the opposing team. The opposing team may choose instead a scrum at the location where the offending team last played the ball. However, if the infringement was accidental then a scrum is awarded at the location of infringement. A player who is in an offside position remains offside until played onside in one of several ways:
a teammate who has remained onside runsahead of the offside player
the offside player runs behind the ball carrier/kicker
an opponent at least 10 metres away from the offside player kicks, passes, intentionally touches, or runs 5 metres with the ball
At a lineout only players in the line, a receiver and a thrower from each team are allowed within 5 metres of the line, however the defending hooker must be at least 2 metres from the line so as not to disturb the other thrower. The remaining players must be more than 10 metres away from the line or they will be penalised. They may move closer only to catch a long throw-in, or after the line-out ends, when the ball or a player carrying it leaves the lineout in any direction. If a player kicks the ball, out of hand, from the dead ball area, players can be in front of the kicker, as long as they do not leave the dead ball area before the ball has been kicked.
A defending player is offside if he/she is less than 10m away from the play-the-ball when the ball is played. He is also offside if, during open play, he is closer to the opposition's try-line than the ball. At a scrum a defending player is also offside if he is less than 5m away from the base of the scrum. An attacking player is offside if he is in front of the ball: if he is in front of a ball which is then kicked, he can be put onside if the kicker subsequently moves ahead of him before the ball is caught. If not, he must stand 10m away from the player who catches the ball or be penalised.