True crabs as well as their close relatives have five pairs of legs, for 10 legs in total. However, some of their legs have evolved to serve purposes besides walking, such as self-defense, food acquisition and swimming.
Crabs and their relatives are members of the order Decapoda, which means literally means “10-footed.” True crabs comprise the infraorder Brachyura, while king crabs, hermit crabs and squat lobsters are members of the infraorder Anomura. Typically, members of Anomura retain a primitive, elongated body form, but king crabs carry their tails folded underneath their bodies, making them appear like true crabs. Hermit crabs have elongated tails, but they usually keep their tails hidden inside a mollusk shell. Although horseshoe crabs share a similar name, they are more closely related to spiders than crabs.
Crabs have legs adapted to a variety of purposes. The first legs of most species have evolved into pinchers, technically called chelipeds, while the last pair of legs of some species have become small swimming appendages, called swimmerets or pleopods. King crabs and a few of their relatives fold their last pair of legs underneath their body while walking. They use these legs to transfer sperm or tend the developing eggs.
Several species exhibit claws of different sizes. For example, the right claw of king crabs is usually much larger than the left claw. Fiddler crabs take this strategy to the extreme, and come equipped with two different sized claws: a normal claw used for food acquisition and an enormous claw, used in territorial and courting displays.
The Japanese spider crab, which despite its name is a true crab and not closely related to spiders, has the longest legs of any crab in the world. Living up to 1,500 feet under the surface of the Pacific Ocean, spider crabs walk across the ocean floor on long stiltlike legs. When fully outstretched, their legs may stretch more than 12 feet from the tip of one leg to the other.