Del:
Anyone who ever had even an elementary introduction to atomic structure wouldn't be asking such questions. So, I assume you aren't very familiar with the subject. Hence forgive the, perhaps, somewhat too detailed explanation.
Atoms are composed of a nucleus 'orbited' by a cloud of electrons. For light elements like hydrogen or helium, the nucleus is very small (one proton-neutron pair for H, two for He -- ignoring isotopes for the purposes of this discussion). For heavy elements, there are dozens of protons and even more neutrons in the nucleus. Because the nuclei are made of protons (charge +1) and neutrons (charge 0), they are overall positively charged, and the amount of their charge is equal to the number of protons a nucleus contains. The number of protons in a nucleus also defines the element itself: one proton -> H, two protons -> He, three protons -> Li, etc.
Normally, elements are neutral -- which means that an atom has no overall charge. To make this happen, we must cancel out the positive charge of the nucleus with the corresponding number of electrons (charge -1 each). Hence, an element would have as many electrons orbiting its nucleus as it has protons in the nucleus. Thus, H has one electron, He has 2, Li has 3, etc.
Due to quantum mechanics, electrons can't orbit the nucleus just anywhere. They are confined to narrow regions of space, called 'orbitals'. The electrons also possess something called a 'spin'. Due to Pauli exclusion principle, no two electrons with the same spin can inhabit the same orbital. So, each 'full' orbital would contain an electron spinning 'up', and an electron spinning 'down'.
The orbitals form a spacial 'hierarchy', i.e. they are arranged in 'levels'. Closest to the nucleus, you have a level 1 'S' orbital which can only contain two electrons. Above this S1 orbital, we have level 2, which contains its own S orbital, and 3 P orbitals; above level 2 we have level 3 with S, P, and D orbitals, and so on.
The further away from the nucleus an orbital is, the higher its energy. Electrons naturally want to occupy the lowest-energy orbital available, to be as close as possible to the nucleus. However, when an atom receives an energy influx, such as from an incident photon, the electrons in its outer shells can be kicked up to higher-energy orbitals. They stay in those high-energy orbitals for a while, but then transition back to the lower-energy orbital, at the same time giving off the excess energy in the form of a photon.
Now, the energy differentials between various orbitals are all different. And, the energy given off by an electron transitioning to a lower-energy orbital is directly represented in the frequency of the photon that is created. Hence, by just looking at the frequency of different photons emitted by excited atoms, and using some black-body emission physics, we can figure out exactly what element the atom belongs to, and what the atom's 'temperature' is.
In addition to emitting at wavelengths specific to their element, atoms also absorb light at very specific wavelenghts. This is how scientists identify elements in stars -- by looking at the 'absorption spectrum' of a star. The spectrum of a star in general is just a plot of intensity vs. frequency -- i.e. y represents how many photons of frequency x we managed to detect in time delta t. Because various elements absorb light at specific frequencies, and re-emit the energy at other frequencies, emission spectra in general tend to have 'absorption lines' in them -- where for certain frequencies the light intensity is much less than for other frequencies. Again, for each element the set of absorption lines, and the frequency spacing between them, is unique. So, by simply performing absorption spectrum analysis of a star, it can be determined what elements, and in what abundance, are present in the star (and especially in the star's outer layers).
In reality, the process is somewhat complicated by the fact that atoms are usually ionized in stars -- i.e. they lack at least one electron from their outer shells -- which somewhat affects their absorption spectra. Nevertheless, ions as well as intact atoms have unique absorption signatures, so direct measurements of element abundance in stars are indeed practical.
I hope I didn't confuse you too much, but the main point is that spectroscopic analysis and absorption spectra apply to light elements just as well as to heavy ones -- there's no fundamental distinction between the two classes, because all elements and their ions have unique spectral behavior.
------------------
I am; therefore I think.