Going back to ancient times, stars were classified by brightness, which gave rise to the current magnitude system to describe stellar brightness and color. This system is quantitative, giving a precise numerical measure of both brightness and color.
With the development of spectroscopy, a new way of classifying stars came into being: stars were classified by the features of their spectra. This is the meaning of the obscure jargon of astronomers describing Sirius (α Canis Majoris) as an “A1 V” star and Pollux (β Geminorum) as a “K0 IIIb” star. The “A1” and the “K0” are spectral classifications, and the “V” and the “IIIb” are luminosity classifications. Unlike the magnitude system, the stellar type system is a pattern-matching system, so the notation tells us which prototype star a given star most resembles.
The spectrum of most stars is a continuum cut by dark bands. The dark bands are absorption lines, created when cool gas above a star's photosphere absorb the starlight from the photosphere. The positions of the lines are set by the chemical composition and temperature of the gas, and the strength of the lines depends on the temperature and density of the gas. Some stars, particularly many of the stars found in the constellations Orion and Canis Major, have spectra with emission lines.
When astronomers first began taking the spectra of stars, they found that the same line patterns kept recurring. At the Harvard College observatory at the end of the 19th century, the astronomers labeled these various spectral patterns with the letters A through Q. For instance, the letter A was given to the spectral pattern containing only hydrogen absorption lines, while O was given to spectra with emission lines. Determining a star's spectral type in this system is an issue of matching the pattern and strength of the various lines.
In time, as astronomers gained experience with this classification system, they consolidated some classes into others, and they learned that the spectral classes formed a continuous sequence. For instance, astronomers learned that the A and F stars were connected by a sequence of stars having a little of each pattern. The sequence of spectral types was found to be O, B, A, F, G, K, and M. When I was a graduate student in astronomy, this was taught as an acronym of the phrase “O Be A Fine Girl Kiss Me.” I haven't a clue as to whether this phrase has bit the politically-correct dust, but it is still a handy way of remembering the sequence.
The sequence of spectral types was adopted by the international community of astronomers, and became the standard for classifying stars in Harvard College Observatory's Henry Draper (HD) catalog, which was published between 1918 and 1925. To describe where between pairs of types a star falls, the Harvard astronomers added a number ranging from 0 to 9. For instance, stars with patterns that fall between A and F would be given the notations A0, A1, …, A8, A9, and F0. This system was further refined at the Yerkes observatory, giving us the system we use today—the Morgan-Keenan (MK) system. The system is describe in the Yerkes Atlas of 1943.
The reason the patterns of spectral lines follow a sequence is that the photospheric temperature determines the spectral pattern in most stars. The hottest stars, the O stars, have absorption lines of ionize helium and emission lines. At cooler temperatures, the emission lines disappear, and one sees the absorption lines of neutral helium and hydrogen, with the hydrogen lines the dominant features. These are classified as B stars, which do not have lines of metals (which, in astronomy jargon, means any element other than hydrogen and helium), and, for lower temperatures, as A stars, which do have the lines of metals. The O, B, and A stars are often referred to as “early type” stars. The F stars have weaker hydrogen lines than the A stars, and they have lines of ionized calcium. The G stars have weaker hydrogen lines than the F stars, strong lines of ionized calcium, and lines of neutral metals. The F and G types are “intermediate types.” In the cool K stars, lines of neutral metals are dominant in the spectrum. In the very cool M stars, the stellar atmosphere contains molecules that create bands of absorption rather than lines. Particularly strong in M stars are the absorption bands of titanium oxide. The K and M type stars are called “late type” stars.
Over 99 percent of all stars are described by the original MK system. To describe the small number of stars that do not fit the system, additional types were added. The type C and S classes were added to describe stars that are similar to type M stars except for some specific sets of spectral lines associated with specific molecules. Both of these classes are considered late-type classes. The C class represents stars with strong spectral lines of carbon. In particular, rather than titanium oxide, the C type stars have band of cyanogen (C2N2), carbon monoxide (CO), and molecular carbon (C2). The S class represents stars with the spectral bands of zirconium oxide (ZrO2). At the high-temperature end of the classification scheme are the W stars, which represent the Wolf-Rayet stars. These are stars descended from the O stars; the Wolf-Rayet stars have lost their outer envelopes of hydrogen, so that their spectra have strong lines of helium, carbon, and other heavier elements.
More recently, two additional spectral types have been added: L and T. These spectral classes describe the spectra of brown dwarfs. The brown dwarfs are the bodies that are smaller than the stars but larger than the gaseous planets. Their distinguishing feature is that they undergo a brief period of burning deuterium, but otherwise all the energy they release is generated through gravitational contraction. Over the past decade, about 500 brown dwarfs have been found. Observations show two different types of spectra, both of which varied from the spectra of the cool M dwarf stars. While the M dwarfs are characterized by lines of titanium oxide (TiO), no such lines are seen in the brown dwarfs, implying that the brown dwarfs are cooler than the M dwarfs. On the other hand hand, the coolest brown dwarfs have lines of methane (CH4) and ammonia (NH3). These coolest brown dwarfs are given the type T. The warmer brown dwarfs, which do not have the lines of methane and ammonia, are designated by L.
Besides the pattern of lines in a spectrum, observers characterize the width of the lines in their classification system. This was originally noted by a roman numeral that runs from I to VII, with the I referring to narrow lines and the VII referring to broad lines. Subclasses have been added to the original number system, so there are IIIa and IIIb subclasses that bracket the III class, the first with a narrower line width, and the second with a broader line width. At the narrow-end of the scheme, Ia, Iab, and Ib have replaced I, with the sequence going from narrow line width to broad line width. The narrowest lines are now labeled 0.
These markers of spectral line width define the luminosity classes of the stars. The stars on the main sequence define the V luminosity class. The stars in classes II and III are called giants, and the stars in class I are called supergiants. The degenerate dwarfs have a VII luminosity class.
The reason that the width of an absorption line is a measure of luminosity is that the width of the line depends on two physical conditions at the photosphere of a star: the temperature and the density. The temperature affects the width because the atoms emitting the radiation are moving with a velocity proportional to the square-root of the temperature, and this velocity causes a Doppler shift of the radiation before it is absorbed by the atoms. Because atoms are moving both towards and away from the observer, some atoms absorb radiation that has been blue shifted, and other atoms absorb radiation that has been red shifted. The net effect is to broaden the line. The density affects the width of lines because collisions between atoms affect the absorption of light, causing the lines to broaden. The higher the collision rate between atoms, the broader the lines. Because the collision rate increases with density, the width of an absorption line increases with density. All stars of a given spectral class have the same photospheric temperature, so the width of the absorption lines is a direct measure of the density. But the physically-larger stars have a more tenuous atmosphere than the smaller stars of the same photospheric temperature. A larger star therefore couples a larger photosphere area to a lower density than does a smaller star of the same spectral type, so the larger star is more luminous and has narrower spectral lines than the smaller star.
Because he luminosity classes are classifications of stars by line width, they do not correspond to fixed values of luminosity as one looks across the range of spectral types. There is only a small difference in luminosity in going from I to V for the early-type stars, but the difference in luminosity is dramatic at the late end of the spectral classification. For instance, for O5 stars, luminosity classes I and V fall within 1 magnitude, for A0 stars, they are separated by almost 8 magnitudes, and for G0 stars, they are separated by 12 magnitudes. The reason is that the I luminosity is nearly constant in absolute magnitude as the stellar type changes, but the V luminosity follows the main sequence in its absolute magnitude as the stellar type changes.
In the MK system, a star's stellar type is determined by comparing the pattern of lines in the star's spectrum to the spectrum of a set of prototypical stars. This means that when we say a star is a type A0 V star, we mean that it has a pattern of spectral lines that resembles those seen in a prototypical A0 V star—for instance, Vega (α Lyrae). One of the prototypical G2 V stars is the Sun.
The stellar type system is a purely empirical classification scheme that simultaneously describes both a star's photospheric temperature and luminosity in terms of the spectral characteristics of a handful of prototypical stars.
Pickering, Edward C. “The Draper Catalogue of Stellar Spectra.” Annals of the Astronomical Observatory of Harvard College 27 (1890): 1–388.
Cannon, Annie J., and Pickering, Edward C. “The Henry Draper Catalogue: 0h, 1h, 2h, and 3h.” Annals of the Astronomical Observatory of Harvard College 91 (1918): 1–290.
Keenan, Philip C. “The MK Classification and Its Calibration.” In Calibration of Fundamental Stellar Quantities, IAU Symposium 111 (1985): 121–136.
 Kirkpatrick, J. Davey. “New Spectral Types L and T.” in Annual Review of Astronomy and Astrophysics, edited by R. Blandford, G. Burbidge, J. Kormendy, and E. Van Dishoeck, vol. 43. Palo Alto: Annual Reviews, 2005: 195–245.