Castling is a special chess move that allows the king to find safety while activating a rook, all in a single turn.
The move is executed by shifting the king two squares toward one of its rooks, which then jumps to the square immediately on the other side of the king. It is the only move in chess that moves two pieces at once. Kingside castling (O-O) brings the king to g1 (or g8 for Black) and the rook to f1 (or f8); queenside castling (O-O-O) brings the king to c1 (or c8) and the rook to d1 (or d8).
Several conditions must all be met: neither the king nor the rook involved may have moved previously; the king must not be in check at the moment of castling; the squares the king crosses and the square it lands on must not be attacked by the opponent; and all squares between the king and the rook must be empty.
In practice, castling early is one of the core principles of the opening. A king left in the center is a constant target, especially in open positions where files open up quickly. Aiming to castle within the first ten moves is a habit that prevents many tactical disasters.
