Stars run on hydrogen fuel. When stars fuse hydrogen into helium, they burn, releasing heat and light. But what happens when they run out of hydrogen? The star starts to contract, becoming smaller. And, as the core of the star contracts, it gets hotter. This makes the upper layers of the star expand, and as the star expands, it turns into a red giant.
When the core is hot enough, the helium starts to fuse into carbon. Once the helium gets used up, the core expands and starts cooling down. The core finally cools into a white dwarf, then a black dwarf. This is what happens when a normal-sized star dies. If a really huge star dies, it has so much mass that after the helium is used up, it still has enough carbon to fuse it into heavy elements like iron. When the core turns to iron, it no longer burns. The star’s gravity causes it to collapse, and then it explodes into a supernova. What’s left of the core can form a neutron star or a black hole.