A planetary nebula (PN or for plural, PNe) appears in the sky as a circular nebula-type object, which at the right distance, resolves to an angular size much like a solar system planet, and many are close enough to be resolved by telescopes. Often they show a surrounding border-ring that is a bit brighter, which is taken as evidence of a sphere-shaped shell of glowing gas. They gained the name planetary nebula from this planet-like appearance, but they aren't directly related to planets.
Planetary nebulae consist of a circumstellar envelope (CSE) which glows from having been ionized by energetic photons from the star within (fluorescence), which has grown hot enough to produce a lot of ultraviolet and X-rays. The CSE is the remnant of the massive stellar wind of AGB stars, which eject their large outer volume of thin hydrogen gas, often in pulses, from thermal pulses within the star. The star continues to heat it from within after fusion dies, after which heating is from contraction of the stellar core. The nebula obscures the now-smaller star (termed the central star of the planetary nebula, CSPN, or planetary nebula nucleus, PNN, or planetary nebula nucleus variable, PNNV if it is a variable star), at some wavelengths hiding it completely. The contracting core is becoming a white dwarf which remains after the planetary nebula has dispersed.
The stars that undergo this stage are massive enough to produce giant star stages but not so massive as to core collapse supernova, i.e., earlier in their life they were within a range of roughly 0.5-8 solar masses. PNs are presumed to live on the order of ten thousand years. Vorontsov-Velyaminov planetary nebula types: