Stars are born inside nebulae, giant clouds of gas and dust that slowly collapse under gravity until the core becomes hot and dense enough for nuclear fusion to ignite. Once fusion begins, a new star is born and enters the longest phase of its life, called the main sequence.
What happens next depends on the star's mass. Smaller stars like the Sun will eventually swell into a red giant, then shed their outer layers and leave behind a dense core called a white dwarf. Much larger stars burn through their fuel far faster and end their lives in a dramatic supernova explosion.
After a supernova, the star's remains can collapse into a neutron star, one of the densest objects in the universe, or in the most massive cases, into a black hole, where gravity becomes so strong that not even light can escape.