What is offsides in soccer?
Simply explained, an offsides infraction is the result of an offensive player getting closer to the opposing team's goal line than both the ball and the last defender. Per the FIFA rulebook, a player is ruled offside "the moment the ball touches or is played by one of his teammates." This means every inch of a player's body, including their head, feet, toes, knees, fingers, etc., have to be in front of the last defender when the ball is passed to them. Otherwise, they'll be ruled offsides.
A player cannot be ruled offsides, however, if they're receiving the ball from a throw-in, a goal kick, or a corner kick.
Because it's hard to visualize, here's a helpful video with a few examples showcasing how it works.