For most "everyday" considerations an atom is composed of positive protons, neutral neutrons, and negative electrons. The protons and neutrons are about the same mass and reside together in the nucleus of the atom. The electrons are much smaller (a proton is about 2000 times the mass of an electron) and reside outside of the nucleus. The position of the electron can only be described in terms of probabilities. Using quantum mechanics the probability of finding an electron within a particular region of space can be calculated, but the exact position is not known. The electrons do NOT orbit around the nucleus like planets around the sun.
All of the atoms of a particular element have the same number of protons, but could differ in the number of neutrons or the number of electrons. If the number of electrons changes, the atom becomes a charged particle and is called an ion.
Each atom has a set of energy levels associated with it. All of the atoms of a particular element have the same set of energy levels, but every element has a unique set of energy levels associated with its atoms. Knowing the energy levels identifies the element.
Each electron in an atom is associated with a particular energy level of the atom. The electrons in the higher energy levels can often become excited by light, heat, electricity, etc. and "jump" to an even higher energy level that is available in the atom. The excited electron will eventually "fall" back down to the lowest available energy. When it returns to the lower energy level energy is given off. If the energy given off is in the visible region, it can be observed with the human eye.
An amazing thing about electrons is that they can only accept the exact amount of energy needed to get to a higher energy level. Less energy or more energy does not cause the electron to "move" out of its present energy level. This is an example of selective absorption of energy. The atom only absorbs the energy associated with a change in energy levels. In the same way the atom only gives off energy associated with a change in energy levels. Since the energy levels are characteristic of an element, the energies absorbed and given off are also characteristic of an element. Each element has its own characteristic line spectrum.
Some molecules also selectively absorb light energy. When they absorb in the visible energy range, we see the complement of the color that is absorbed. That is why leaves are green. The chlorophyll in the leaf absorbs the compliment of green and we see green. The blue color of water is also due to selective absorption of light by the water molecules. This is much different from the scattering of light which is responsible for the blue sky.
Quantum mechanics predicts selective absorption of energy by atoms and molecules. The discrete nature of energy levels is required in quantum mechanics.
Light can be described in terms of energy (E), wavelength (lambda), or frequency (nu). These are related in the following way: