Stars are born from clouds of gas and dust called nebulas. As the gas spins faster under gravity, it heats up and forms a protostar. Nuclear fusion then occurs, turning the protostar into a main sequence star that shines for millions of years by fusing hydrogen into helium. Eventually the hydrogen runs out, causing the star to expand into a red giant. From there, less massive stars will blow off their outer layers and collapse into white dwarfs, while more massive stars will explode in supernovas and collapse into neutron stars or black holes.