The basic thought behind stellar classifications is that all stars start out as hydrogen, and that the major difference between types is the mass of the star. As a star ages, it advances in stages through burning hydrogen, helium, carbon, and heavier elements. As this happens, the spectrum of the star changes, and it becomes brighter, advancing up the Main Sequence.
The absorption lines represent chemical elements in the star's atmosphere. You can also tell a star's temperature by looking at the overall spectrum curve and applying the Stefan-Boltzmann law. When you do that, it's clear that generally the brightest stars are also the hottest. If you plot a large number of stars on a chart with brightness on one axis and temperature on the other, most stars will fall on a line called the Main Sequence. A chart like that is called a Hertzprung-Russell diagram.
The classification of stars is by temperature (which you can always determine) rather than brightness (which can be tricky). So for example, all G1 stars are the same temperature (actually, same temperature range), regardless of their brightness or whether they're on the Main Sequence or not.