Environmental conditions play a role in the colors that leaves change to during autumn. Even as the leaves are dying, they are helping the trees prepare for winter. (John McDonnell/The Washington Post)

It wouldn’t feel like fall without the sight, smell and oh-so-familiar crunch of fallen leaves. But why do some trees change their colors — and then give up their leaves — as autumn sets in?

First, a bit about why leaves are usually green. Humans have to eat food to get the nutrients that keep us alive, but plants use the sun to power photosynthesis (pronounced fo-toe-SYN-thuh-sis), which turns water and the carbon dioxide in air into delicious, nutritious sugar. The secret to this sweet process is chlorophyll (CLORE-o-fill), which absorbs sunlight and happens to be green.

As winter approaches, the sun stays up for less time every day. That makes it hard for chlorophyll to keep trees sugared up, leaving them dependent on extra food from the summer. Trees stop producing new chlorophyll, because doing so would be a waste of energy, and soon there’s none left.

That explains where the green goes. But where do all those oranges and reds and yellows come in?

Chlorophyll usually steals the spotlight, but leaves also contain other pigments (that’s a substance that provides color), including the ones that make carrots orange and turn egg yolks yellow. Without chlorophyll’s green, these pigments finally make themselves known.

Sometimes, trees also produce the same red pigments that give raspberries their color. Leaves make those red pigments only in the fall, and scientists aren’t sure why it happens. But it must be for a good reason, because it takes a lot of sugar — which the tree needs to save up as much as possible. One guess is that these deep reds help protect dying leaves from sun damage, allowing them to collect energy just a little longer. They may also serve as a warning to animals that might otherwise eat or lay eggs on the leaves.

The exact coloring of fall foliage is the result of a mix of these red, orange and yellow pigments. So environmental conditions that change how much there is of each — such as sun exposure, soil moisture and temperature — can make a big difference. Colors vary by species, too.

Eventually, sunlight and frost kill off all pigments but tannin, which is brown. The very cells of the leaf will break down as well, making them fragile and dry. Meanwhile, the tree creates corklike cells to seal itself off from its leaves, even creating a sort of scab where each one connects to the branches. Eventually wind or some other disturbance will break the dying leaf away, leaving the tree with a tiny scar.

That’s how we get those brilliant bursts of color — and wonderful leaf piles to hop around in. In the spring, trees get to make new leaves and start the whole process again.

Clarification: An earlier version of this story stated that photosynthesis turns water and air into sugar. Only the carbon dioxide in the air is used in photosynthesis. The story has been updated.

Feltman is the science editor for Popular Science Magazine.