Wikipedia article on "offside" is very comprehensive and largely based on the official IFAB Laws of the Game.
From the article, what it is: Offside is a law in football which states that if a player is in an offside position when the ball is touched or played by a teammate, he may not become actively involved in the play.
A player is in an offside position if he is closer to the opponent's goal line than both the ball and the second-to-last defender (which is usually the last outfield player), but only if the player is on his opponent's half of the pitch.
How it is officiated: In enforcing this rule, the referee depends greatly on an assistant referee, who generally keeps in line with the second-to-last defender, the ball, or the halfway line, whichever is closer to the goal line of his relevant end.
An assistant referee signals that an offside offence has occurred by first raising his or her flag upright without movement and then, when acknowledged by the referee, by raising his or her flag in a manner that signifies the location of the offence
So in my own simple words, you determine an offside by:
At the time when the ball is played (pass or kick down the field) note where the second last defender (usually the last defender as the goalkeeper is usually furthest back of any, but not always!)
of the defending team is and where is the player(s) of the offending team (who are involved in the play*)
are further down the field from the ball
Draw a line parallel to the base line (goal line) of the pitch through the said players
If you see that the line going through an offending player who is about to receive the ball is closer to the goal than the line going through the last defender, and that line is in the defending half, then it is an offside. by "involved in the play" we mean that they are likely to either receive the ball as a result of the pass in question or are able to influence the outcome of the play in some other way.
A player would not be considered involved if he is on the other side of the pitch with the ball going away from him.
Refer to the Laws of the Game for more info.
Notice that there are a few exceptions when someone can be or not be offside.
When a ball is brought back into play after it left the pitch, one can never be offside.
So, one can never be offside after directly receiving a ball from a throw-in, goal kick, corner kick or a kick off (of which the latter two are rather trivial).
From a (indirect) free kick one can be called offside, since the ball had not left the pitch.
Suppose someone shoots for goal while his teammate is in offside position.
When the ball then returns from the post, the bar or even the goalkeeper and comes in the possession of the teammate, he is still offside.
Offside is not bounded by the lines of the pitch.
So, one can still be offside or prevent an opponent from being offside while being out of play.
See gbianchi's answer to this relevant question .
sports.stackexchange.com/users/34/Dmitry Selitskiy
A Picture is worth thousand words!
Hope this helps you understand
sports.stackexchange.com/users/336/Rohit Vipin Mathews
I've noticed that football players often talk about being level with the second last defender; but the FIFA offside rule is now much more precise.
At the instant the ball leaves the attacking player the offside vertical plane is fixed at the part of the second defender (other than his arms) which is closest to the goal line.
At that instant, if any part of another attacking player has any part of their body (except the arms)
beyond that plain they are potentially offside.
sports.stackexchange.com/users/480/Dlg
A couple of quick additions, which I have not seen mentioned in previous answers (it's late and I am very tired
so I might have missed, if that's the case I'll remove this answer)
There is a scenarios which might be confusing; a player is not off-side if; beyond the second lass defender but the pass to him comes from a team mate that is further ahead of him i.e. if the pass is backwards (similar to rugby)
There is a pretty nice guide which explains the concept in detail, with illustrations.
sports.stackexchange.com/users/364/posdef
A bit stupid to make this an answer
but it's not yet (completely correct) on here.
And I can not comment yet, so here goes:
In addition to posdef's answer: you can be in an offside position if a player passes backwards as much as with a forward pass.
As long as the player stays behind his teammate it does not matter in which direction the pass is given.
But if he is in front of his teammate and gets the pass played at him in backward direction he is still in an offside position.
sports.stackexchange.com/users/7723/Don_Biglia
I used to help ref soccer games when I was younger and the way I was taught to call the off-sides penalty was that if the player on offense was beyond the last defender (goalie doesn't count obviously) before the ball was also beyond the last defender, then the player is off-sides.
Some people (myself included) think the way it should be called is that the player on offense needs to be even with the defender, but should be allowed to pursue the ball as soon as it is passed to them, regardless of their position relative to the other teams defensive players.
In other words - let one players speed and instinct give them an advantage - rather than a penalty.
sports.stackexchange.com/users/18/jamauss
The offside rule on the pitch is often unclear and called suddenly. How do I know if a player is offside?
How is offside determined in football?
sports.stackexchange.com
<football><rules><officiating>
sports.stackexchange.com/questions/3
sports.stackexchange.com/users/6/wax eagle
A player is in an offside position if he is closer to the opponent's goal line than both the ball and the second-to-last defender (which is usually the last outfield player), but only if the player is on his opponent's half of the pitch.     Football defines offside as the position of a player closer to the opposing goal post than the ball and the other team's last defender, not including the goalkeeper. Any player in an offside position should not participate in the game actively. Offside may apply for indirect kicks, both for forward and backward passes.
Football defines offside as the position of a player closer to the opposing goal post than the ball and the other team's last defender, not including the goalkeeper. Any player in an offside position should not participate in the game actively.  Offside may apply for indirect kicks, both for forward and backward passes.