The interstellar medium is made up of material in the intermediate stage between stellar death and stellar birth. When most stars die, they eject some of their mass into the surrounding space. This happens either violently in a supernova explosion, or more typically in something less violent like the formation of a planetary nebula like the famous Ring Nebula. Stars can also lose material in a persistent stellar wind like the solar wind. This ejected material, mostly hydrogen and helium but enriched by heavier elements formed in the star or during the ejection process, can then accumulate into new clouds of gas and dust which may form new stars and planets.
The following photo of the Milky Way in the constellation Cygnus shows a variety of these clouds. The dark areas running across the middle of the photo are "dark nebulae" where dust is scattering the light coming from behind and dimming the background stars. The obvious (but small) red patches on the left side of the photo are "bright nebulae" or "emission nebulae". In this case, the gas is being heated by nearby stars and is glowing in a manner similar to a neon light.
If a star behind one of those clouds is bright enough, we can still see it and observe the signature of the intervening interstellar material on the star's light. This is often done by taking spectra of the star's light, wherby the light is broken up with a prism or similar device into its constituant colors. If you look closely enough at this spectrum, you can locate areas where some of the light is "missing", which either represents processes in the outer layer of the star itself, or absorption of light in the interstellar material.
Below is a portion of the spectrum of a star behind an interstellar cloud. "Flux" is just a fancy term for how bright the object appears and wavelength represents "color". This observation is in the ultraviolet part of the spectrum, so the usual ideas of "color" don't apply, but the principle is the same. The point is that all of those tick marks above the spectrum indicate "dips" due to the absorption of light by hydrogen molecules. By measuring those dips, we can determine how much hydrogen gas in present in the interstellar cloud. We can do the same with other substances. In fact, I am currently working with a large group on a funded research project to study some "dips" for which we can't figure out exactly which chemical is responsible.