Emission and Absorption Spectra
More accurately, a gas cloud is only opaque within spectral lines, while a star is opaque at all wavelengths. The brightness of each depends on the usual T4 relation. If, as is usually the case, the cloud is colder than the star (or the star’s atmosphere is colder than its surface), then an absorption line spectrum is produced. If one looks only at the cloud, the background (empty space) is even colder, so you always get an emission line spectrum. If you look at a cloud through a hotter cloud of gas, you will get an emission line spectrum which includes a continuum.