Your king is priceless: if it’s checkmated, the game ends. Castling is a special move that helps you get the king to safety and activate a rook at the same time. This page shows what castling looks like (both sides), when it’s legal, and the most common reasons to castle early.
Early in the game there is usually a battle for the center. It’s often a good idea to move the king away from the action to a safer corner, and to bring a rook closer to the middle where it can take part in the game. Castling allows you to do this.
Looking from White’s side, the left half is the queen-side and the right half is the king-side. You may castle to either side depending on the position.
When you castle, the king moves two squares toward a rook, and the rook moves to the square immediately on the other side of the king. (In over-the-board play, always move the king first so it’s clearly a castle.)
In the diagram below, neither king has castled yet:
Here the white king castles king-side (short). The king moves two squares to the right, and the rook comes to the square next to the king on the other side. This is written O-O.
Here the white king castles queen-side (long). The king moves two squares to the left, and the rook comes to the square next to the king on the other side. This is written O-O-O.
Castling is a special move where the king moves two squares toward a rook and the rook moves to the square next to the king.
You cannot castle if the king or that rook has moved, if pieces are between them, if the king is in check, if the king would move through check, or if the king would end up in check.
Yes—kingside (O-O) or queenside (O-O-O), as long as the conditions are met.
Next up: the special pawn capture called en passant.