Definition
The speed of sound is how fast sound travels through a medium (a material that carries waves), such as air, water, or a solid. Sound moves because the tiny particles in a material bump into each other and pass a vibration along, so how fast it goes depends a lot on the surroundings and the state of the material.
Why you hear thunder after you see lightning
Have you ever watched a flash of lightning on a rainy day, then waited a long while for the rumble of thunder? Lightning and thunder happen at the exact same moment inside the cloud. So why do they seem to arrive separately?
The reason is that light and sound reach your eyes and ears at very different speeds. Light is almost unimaginably fast. It could circle the Earth about seven and a half times in one second. Sound in air only covers about 340 meters (about 1,100 feet) in one second.
So if you count 3 seconds in your head between the flash and the thunder, the lightning struck about 1 kilometer (about 0.6 miles) away. You can't see sound, but in the same air, the vibrations of air particles get passed to their neighbors at a nearly constant speed as the sound spreads out.
Sound is much faster in water or a steel pipe
In the empty vacuum of space, you can scream as loud as you want and the sound goes nowhere. There are no air particles to carry it. Those big spaceship explosions in movies? Scientifically, no one could hear them.
Sound is a vibration in which tiny particles bump the particle next to them and then spring back into place. The more tightly particles are held together, like balls connected by springs, the faster a nudge to one pulls its neighbor along. So the speed of sound depends less on how crowded the particles are and more on how firmly they are connected.
In water, where particles hold on to each other more tightly than in air, sound travels about 4 times faster. In hard solids like iron or steel, it travels a whopping 15 times faster than in air. That's why people in old Westerns pressed an ear to the railroad track: they could pick up a far-off train before they could hear it through the air.
To be more precise, it depends on temperature
When people talk about the speed of sound, they often treat 340 meters per second as a fixed number. But the speed of sound in air keeps changing with the temperature around it.
When the air warms up, its molecules absorb heat energy and move around faster and more actively. Because the molecules are already zipping around, they bump into their neighbors and pass the vibration along much sooner.
At 0°C (32°F), sound travels about 331.5 meters per second. For every 1°C the temperature rises, it gets faster by about 0.6 meters per second. The familiar 340 meters per second you learn in textbooks is actually the value measured in mild air at around 15°C (59°F).
Common misconceptions
The speed of sound is always the same, everywhere.
The speed of sound keeps changing with the material it passes through (air, water, or a solid), including that material's density and elasticity, and with the surrounding temperature.
In space, you'd hear a huge boom if a giant planet exploded.
Sound travels by passing vibrations from particle to particle, so in the vacuum of space, where there are no air molecules to carry it, no sound can travel at all.
Where you meet it
When you watch fireworks far away, you see the colorful burst first, then hear the boom 1 to 2 seconds later.
The splashing you hear while underwater in a swimming pool travels through the water about 4 times faster than it would through air.
In one sentence
Sound travels by passing along the vibrations of particles. It moves faster in solids, where particles are tightly connected, and in air it moves faster when the temperature is higher.