# How did we differentiate lights from stars?

I got this question while watching the COSMOS TV series. I couldn't find the right answer in google.

I read about Stellar classification and it states that we can classify the stars based on their spectral characteristics. My question is how can we be sure of which particular star the light is coming from. Since Earth is getting light from so many stars How the the light is classified? Even if we can get different spectra then how can find their exact sources?

There are many ways of classifying a spectrum, Stars have continuous spectra crossed by dark lines. The temperature of the star changes the spectrum, the stars are classified in order O B A F G K M from hottest to coolest. Nebula sometimes have emmission spectra which looks mostly dark, crossed by bright lines.