How is a planetary nebula formed?
When most of the hydrogen is finished the stars start to swell.
Stars like Sun is in equilibrium with radiation push outwards and gravity pulls in wards. When most of hydrogen is finished the mass become less.Pull of gravity is reduced and the star began to swell to red giant.. Slowly outer layers are puffed out and forms planetary nebula.Inner core become a white dwarf,
picture slideshare .net.