Stars are formed from clouds of dust and gas that collapse under gravity. Most stars spend around 90% of their life fusing hydrogen into helium through nuclear reactions. When stars run out of fuel, their cores collapse and they expel their outer layers, forming planetary nebulae. This leaves behind dense, hot cores known as white dwarfs. More massive stars may explode as supernovae when nuclear fusion can no longer counter gravity, or collapse entirely into black holes.