(CNN)Sharks are some of the ocean's top predators. In fact, sharks and their relatives were the first vertebrate predators on Earth.
Shark fossils date back more than 400 million years -- that means sharks managed to outlive the dinosaurs, survive mass extinctions, and continue to serve an important role near the top of underwater food chains.
After millions of years of adaptations, more than 500 species of sharks swim the planet's oceans today, and sharks are found in almost every type of ocean habitat. So how have sharks evolved to suit their environments?
From ancient ancestors to modern sharks
To understand how modern sharks adapted and evolved, we first have to look back through the fossil record of their ancestors.
Originating from a time before dinosaurs walked the earth, the earliest shark scales date back about 425 million years, and the earliest shark teeth are from the Devonian Period, about 410 million years ago. And some fossils of shark-like chondrichthyans scales (from a group of fish including sharks, rays, and their relatives) date as far back as 440 million years.
Because shark skeletons are made of soft cartilage, which doesn't fossilize well, most of what scientists know about ancient sharks comes from teeth, scales and fin spine fossils. But the cartilage of early sharks would also be similar to shark cartilage today, which distinguishes sharks from most fish that have heavier skeletons made of bone. Having a skeleton made of lightweight cartilage allows sharks to conserve energy and swim long distances.
"From some of the soft tissue we have found fossilized, early sharks would have had a similar body plan to most modern day sharks," said Emma Bernard, fish fossil curator at the British Natural History Museum.
That means sharks' bodies were tapered at both ends and the fins were in similar places, optimized to make them high-speed predators. But the size of sharks varies greatly. Present-day sharks can range from about 1 to 55 feet. And according to Bernard, sharks about 60 feet long (18 meters) exist in the fossil record.
"The common thread is that they exploit different parts of the marine ecosystem," Bernard explained. "So the more generalist an animal is the more likely it will be to adapt and survive changes in its environment, and the group as a whole will survive."
Wide variety of sharks and adaptations
Teeth are one good illustration of how modern day sharks evolved in different ways. Many early sharks had conical, non-serrated teeth. Meanwhile, many sharks today evolved to have triangular teeth that were flat and serrated like a steak knife, which helps them bite off chunks of prey.
But not all shark teeth are the same. Some bottom-dwelling sharks that feed on mollusks have teeth suited to grinding and cracking shells open. Others, such as goblin sharks (which have a crazy jaw protrusion), have needle-like teeth used for piercing fish. And the biggest fish in the ocean, the filter-feeding whale shark, eats plankton and doesn't actually use its 300 rows of pointed teeth to eat.
"The most interesting adaptation for me, as someone who studies shark feeding, is probably their flexibility in diet," said shark evolution researcher Lisa Whitenack in an email. "If one prey type decreases in abundance, then they could potentially switch to something else."
Sharks also have a wide variety of migration patterns. Marine conservation biologist David Shiffman said. He once saw a nurse shark stay under the same rock for a week.
"But some shark migrations are thousands of miles," Shiffman said. "It's amazing how far they can swim and for how long."