Summary A star forms from interstellar gas drawn together by gravity, which compresses and heats the gas to form a protostar.
Further heating causes the core of the protostar to fuse hydrogen into helium.
The energy released keeps the core hot and thereby maintains an outward pressure that stops the protostar's collapse and changes it into a main-sequence star. When the hydrogen is exhausted in a star's core, the core shrinks and heats, making the star swell into a red giant. The energy released expands the core, and the outer layers shrink, turning the star into a yellow giant. As the star burns helium, its core again shrinks, and it once more becomes a red giant. It is so luminous now that its radiation drives off its outer layers to form a planetary nebula shell.