Battlements line the top of the walls of castles or forts. The walls switch between being low and being high, creating spaces.
Archers can stand in a space and fire an arrow at a castle invader, then run behind a higher section of the battlement to protect themselves from an incoming arrow.
Battlements are also known as crenellations. The higher sections of battlements that offer full protection are parapets. The lower sections that allow visibility are called crenels.