the life of a star begins in a nebula, a nebula is a large cloud of dust and gas in space that acts as a nursery for forming stars.
gravity then pulls some of the gas and dust from the nebula and forms a contracting cloud called a protostar, the protostar is the earliest stage of a star's life.
a star is then formed when dust and gas from the nebula start heating up and soon becomes so hot that nuclear fusion starts. the nuclear fusion then creates what's called the main sequence star
when the main sequence star begins to run out of hydrogen fuel , the star becomes a red giant.
after the star becomes a red giant its outer parts begin to grow bigger and drift off into space, then those outer parts end up forming a cloud of gas called the planetary nebula
the hot core (which is whiteish bluish) of the star that's left behind cools and becomes a white dwarf. eventually, the white dwarf begins running out of fuel and dies as a black dwarf