Stellar classification

In astronomy, stellar classification is a way of grouping stars by temperature. Star temperature can be measured by looking at its spectrum, the type of light that the star shines.
Stars are also grouped into spectral types or classes by color. In general, a star's temperature determines its color, from red to blue-white. Spectral types are named with a letter. The seven main types are "M", "K", "G", "F", "A", "B" and "O". "M" stars are the coldest stars and "O" stars are the hottest. The full system contains other types that are hard to find: "W", "R", "N", and "S". There are also "failed" stars, called brown dwarfs, have spectral types of "L", "T", and "Y". 
The closest star to the Earth, the Sun, is a class G star.
Harvard spectral classification.
The Harvard classification system is a one-dimensional classification scheme. Stars vary in surface temperature from about 2,000 to 40,000 kelvin. Physically, the classes indicate the temperature of the star's atmosphere and are normally listed from hottest to coldest, as is done in the following table: 
Note: The conventional color description describe only the peak of the stellar spectrum. However, the actual apparent colors the eye sees are lighter than the conventional color descriptions. 
The mass, radius, and luminosity listed for each class are appropriate only for stars on the main-sequence portion of their lives and so are not appropriate for red giants. The spectral classes O through M are subdivided by Arabic numerals (0–9). For example, A0 denotes the hottest stars in the A class and A9 denotes the coolest ones. The Sun is classified as G2.
The Hertzsprung-Russell diagram is more often used in astronomy. It relates the absolute magnitude and the surface temperature. It is as important to astronomy as the periodic table is to chemistry.
Conventional and apparent colors.
The "conventional color" descriptions are traditional in astronomy, and represent colors relative to the mean color of an "A-class star" which is considered to be white. The "apparent color" descriptions are what the observer would see if trying to describe the stars under a dark sky without aid to the eye, or with binoculars. 
The Sun itself is white, though it is sometimes called a yellow star. This is a natural consequence of the evolution of human optical senses: the response curve that maximizes the overall efficiency against solar illumination will by definition perceive the Sun as white, though there is some subjective variation between observers.
Class O.
Type O stars are stars with temperatures of ~35,000 degrees Celsius or Kelvin. They are blue in color and can be more than 6.5 times bigger than the Sun. They are also very massive but, at the same time, very rare.
Examples:
Class B.
Type B stars are blue stars which have temperatures of ~25,000 degrees (Celsius or Kelvin). They are high in helium spectral lines and luminosity (brightness compared to the Sun), with moderately strong hydrogen lines. B type stars with Balmer lines in their spectra are part of the Be stars subtype.
Examples:
Class A.
Type A stars are white stars which have the strongest hydrogen lines. They are some of the brightest stars in the sky. Temperatures ~10,000 degrees Celsius or Kelvin.
Examples:
Class F.
Type F stars are yellow stars that contain dominant calcium lines in their spectra. They have temperatures of ~7,500 degrees Celsius or Kelvin.
Examples:
Class G.
Type G stars are yellow stars with temperatures between 5,700-6,400 degrees Kelvin. Ionized calcium and iron are present in their spectra.
Examples:
Class K.
Type K stars are orange to orange-red stars with temperatures between 4,100-5,100 degrees. Molecules begin to appear in weak spectral lines.
Examples:
Class M.
Type M stars are the most common type of star in the universe. Red dwarfs, smaller than the sun, temperatures 3,000-4,000 degrees Kelvin and more common than red giants, which are old 3,100 degree Celsius stars in the last stages of their life. Red hypergiants are also the biggest stars, while red dwarfs, having a fully convective structure, exhaust their hydrogen fuel very slowly compared to other stars. These stars are cool enough to allow molecules to exist intact in their atmosphere; these leave many dark spectral lines.
Examples: