Many nebulae or stars form from the gravitational collapse of gas in the interstellar medium or ISM. As the material collapses under its own weight, massive stars may form in the center, and their ultraviolet radiation ionises the surrounding gas, making it visible at opticalwavelengths. Examples of these types of nebulae are the Rosette Nebula and the Pelican Nebula. The size of these nebulae, known as HII regions, varies depending on the size of the original cloud of gas. These are sites where star formation occurs. The formed stars are sometimes known as a young, loose cluster.
Some nebulae are formed as the result of supernova explosions, the death throes of massive, short-lived stars. The materials thrown off from the supernova explosion are ionized by the energy and the compact object that it can produce. One of the best examples of this is theCrab Nebula, in Taurus. The supernova event was recorded in the year 1054 and is labelled SN 1054. The compact object that was created after the explosion lies in the center of the Crab Nebula and is a neutron star.
Other nebulae may form as planetary nebulae. This is the final stage of a low-mass star's life, like Earth's Sun. Stars with a mass up to 8-10 solar masses evolve into red giants and slowly lose their outer layers during pulsations in their atmospheres. When a star has lost enough material, its temperature increases and the ultraviolet radiation it emits can ionize the surrounding nebula that it has thrown off. The nebula is 97% Hydrogen and 3% Helium with trace materials. The main goal in this stage is to achieve equilibrium.