An absorption line depends on the population of its lower atomic level, ionization state, transition strength, pressure and broadening, not just elemental abundance. Boltzmann distribution changes excitation populations with temperature, while the Saha equation changes ionization with temperature and electron pressure. Thus similar overall composition can produce very different spectra. Molecules survive preferentially in cool atmospheres.
The Harvard spectral classification orders the main stellar classes by decreasing effective temperature: O, B, A, F, G, K, M, from blue to red. Numerical subclasses run approximately from 0, the hotter end of a class, to 9, its cooler end. An A0 star, near , has very strong Balmer series lines; hotter stars ionize much of the hydrogen and cooler stars underpopulate its level. A G2 star, near , has weaker Balmer absorption, many neutral and ionized metal lines, prominent Ca II H and K lines and the CH G band. An M5 star, near , has strong TiO molecular bands, neutral-metal and alkali features, and weak photospheric Balmer absorption.[ref]
For giant and dwarf stars of the same colour, compare gravity-sensitive line widths and ratios. The giant's larger radius gives lower surface gravity and atmospheric pressure, typically narrower pressure-broadened lines; high-pressure dwarf atmospheres have stronger broad alkali wings and different molecular and ionization ratios. These diagnostics assign a luminosity class, such as III for a giant and V for a dwarf. A line ratio or calibrated gravity indicator is stronger evidence than colour alone.