Many nebulae or stars form from the gravitational collapse of gas in the interstellar medium or ISM. As the material contracts, massive stars may form in the center, and their ultraviolet radiation ionises the surrounding gas, making it visible at optical wavelengths.