A planetary nebula (PN or for plural, PNe) appears in the sky as a generally-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, and the term is used for non-circular nebulae of analogous origin.
A planetary nebula consists of a circumstellar envelope (CSE) which has been ionized by energetic photons from the star (which has grown hot enough to produce substantial ionizing radiation), i.e., ultraviolet and X-rays and the resulting plasma glows at a lower, visible wavelength through fluorescence. 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. When the star can no longer sustain fusion, which has been maintaining the star's size, it shrinks from gravity, increasing the mass of its electron-degenerate stellar core, and increasing its temperature through the Kelvin-Helmholtz mechanism. 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 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: