By looking at all the stars in the heavens, each at a different point in its history, astronomers have worked out how a star evolves. The sequence varies with the size of the star. When they are dying, the smallest stars become black dwarfs, not red giants or supergiants. The biggest stars end up as black holes. Mid-range stars become white or black dwarfs, or supernovae and neutron stars.
Stars begin life as clouds of dust and gas called nebulae.
Clumps of dust and gas are pulled together by their own gravity. The star begins to shine. With most stars , because the heat in the core pushes gas out as hard as gravity pulls it in, the star becomes stable. Eventually, hydrogen in the core is almost used up, but surrounding gas burns on and the star swells into a cool red giant. In the core of a supergiant, the pressure may fuse even heavy elements, making iron.