OFFSIDE
First, it is important we clear one thing up. Notice the rule is OFFSIDE and that there is no S at the end. This is one misconception people make all the time in talking about the rule.
The reason for this has to do with the origin. The offside rule essentially states a player is momentarily off their side. When the game first originated, players would literally hang out by the goal while play was taking place on the other side of the field. Hence, the offside rule was created.
At its essence, offside means that an attacker is on their opponents side of the field. They are also closer to the goal than the second to last defender. In short, an attacker can not be closer to the goal than the last two defenders when on their opponents side of the field. Being even with the second to last defender is allowed...but keep reading for an exception.
The following picture shows a basic example:
Note that the Attacker has only one defender between him and the goal.
It should be noted that there is no foul for a player to be in an offside position. They can stand there the entire game and not be called offside. However, once the player becomes active in the play, then they are called offside. They can be called offside by being active in the following ways:
1) actively playing the ball when kicked forward;
2) if being in an offside position gives them unfair advantage when the ball is played and they do not actively go for the ball (it might deflect off a defender or the goal and go to them)
3) if they interfere with a defender who may be attempting to play the ball.
Also, all of this has to happen at the time the ball is kicked.
So if a player is in an offside position at the time the ball is played forward and one of the three incidences above is taking place, the player is called offside. It does not have to be their whole body in the offside position. If a playable part of their body is closer to the goal than the second to last defender, they can be called offside (for example, a head or foot can be closer and the player called offside, but a hand or arm that may be closer cannot be used to determine offside).
HOWEVER, there are exceptions to this rule:
1) A player cannot be called offside on a throw-in, corner kick, or goal kick
2) A player cannot be offside on their own side of the field.
3) If the ball is deliberately played by a defender and they are in an offside position, they cannot be called offside.
Two final things need to be pointed out. First, offside is one of the easiest rules to understand once you understand the basics. If you do not fully understand it, then it is a challenge to comprehend. Secondly, from most of the field, determining is a player is offside or not can equally be challenge. This is why referees are trained to line themselves up with the second to last defender so they can have the best angle of view to determine offside.
There are other more complicated circumstances and "plays" that determine offside or not. If you would like to know more, feel free to discuss with a referee, or you are welcome to undergo the training yourself. Overall, the explanation gives the basic knowledge to understand offside in any situation.
The following video will help explain it as well.