To visit the Blue Grotto (Grotta Azzurra), you need to reach the entrance of the cave by land or sea. There, all visitors must board small rowboats, the only kind of boats that are allowed inside the cave. The grotto closes in case of rough seas or high winds, so you can't book a ticket in advance to visit the cave itself but only a boat tour that includes a stop at the cave entrance. Tickets to the grotto must be purchased directly at the cave entrance (there is a floating ticket office).
More information about the Blue Grotto (Grotta Azzurra)