All elements and compounds absorb light or energy at some point along the electromagnetic spectrum. To measure gasses, we're simply taking advantage of the unique and specific wavelengths where molecular absorption and resonance occur.