Remember that when light from a source (say, a star) passes through a cloud of gas you get absorption lines that correspond to the elements within the cloud.
Also, if you observe just the irradiated cloud, not the blackbody through the cloud, you see emission lines.