Stars are born when a nebula contracts and forms a protostar. Most stars spend about 90% of their lifetime on the main sequence fusing hydrogen into helium. Later in their lives, stars grow into red giants and then supergiants as they fuse heavier elements. When stars die, they expel their outer layers as planetary nebulae, leaving behind dense white dwarfs, neutron stars, or black holes depending on their original mass.