The term planetary nebula is highly erroneous, as these emission nebula have nothing whatsoever to do with planets. Perhaps the most famous of these is the beautiful ring nebula in Lyra, not far from the brilliant star Vega, although many other planetary nebula are scattered around our night skies, and can be observed comfortably in larger telescopes.
The following video by ESA is a fantastic 3D model of the Ring nebula. In essence the ring nebula is the remnants of a dying Sun like star beyond its red giant phase. As the star enters its final stages its outer layers are shed in great expanding waves, and the residual hot white dwarf star at the centre ionises these gases into beautiful coloured shells.
This ionisation process is very similar to the mechanism that produces Earth based aurora. Electrons are recaptured within the host atoms (often hydrogen, helium, oxygen and nitrogen) and the drop to lower energy levels releases light of a specific frequency, governed by the simple equation we all learn in physics, E = hf.