A three-way switch is recognizable by its three terminals plus ground screw. Three-way switches are used in pairs to control a single device. Either switch can turn the device on and off, regardless of the position of the other switch. The most common application is a light in a stairway that's controlled by a three-way switch at the bottom of the stairs and a second three-way switch at the top.
Two of the terminals are called traveler terminals. A traveler wire runs between a traveler terminal on each switch. A second traveler wire runs between the other traveler terminals. The remaining terminal on each switch is the common terminal. One common terminal connects to the power source; the other connects to the hot lead on the light.
Flipping the switch back and forth determines which traveler wire carries the current.
A three-way switch with a single three-wire cable coming into the box is at the last position in a circuit or at the end of a run. The black wire leads back to the power source. It connects to the common terminal and provides power to the circuit. The red and white (marked with black) traveler wires connect to the traveler terminals on the other three-way switch. The black wire on that switch connects to the light or whatever device the switches control. The white wire is marked with a piece of black tape to indicate it can sometimes be hot.
A three-way switch in the middle of a run has two cables entering the box -- one with two wires, the other with three. The black wire from the two-wire cable connects to the common terminal. It leads back to the power source from one switch and to the device the switches control from the other switch. The white wires are joined. The remaining wires are the travelers, which run between the traveler terminals on the two switches. The white traveler is marked with a piece of black tape to indicate it can sometimes be hot.