I'd like to know what causes the wavelengths of the emission spectra of different elements. I know that every element has a different emission spectra, but what determines the wavelengths present in a spectra of any given element? I've heard that it may have something to do with the electron energy levels, but I don't know if that is correct. An in detail explaination would be most helpful. Thanks in advance for any help.
The big concept to focus on here is the Bohr Model of the atom:
Imagine that a photon propogating with a very particular amount of energy interacts with an electron in a ground-state ($n = 1$) hydrogen atom (here we use hydrogen due to its simplicity; it's just a proton and an electron). If the energy of the photon is just right, the electron will absorb it and move up to, say, the $n=3$ energy level, having gained the energy from the photon. Naturally, the electron will "fall" back down to the ground state much like a ball rolling down a flight of stairs where each stair is increasingly further away as it rolls down.
When it "falls" back down, the electron has to lose some energy to enter the lower energy state. This energy is lost as radiation, and is very particular to which energy levels the electron moves between.
As you can see in the picture, an electron in a hydrogen atom falling from $n=5$ to $n=2$ (i.e., straight down to the first excited state), emits a much larger amount of energy at once, which in this case is a photon with a frequency in the violet range, as opposed to the transition from $n=3$ to $n=2$, which is that red hydrogen line (656nm wavelength) we all know and love. As a side note, all emissions of an electron moving down to $n=2$ in a hydrogen atom from any other energy level are part of the Balmer series
Now if you have something like magnesium, the first few valence levels ($n=1$ and $n=2$ are all filled up, because the first level "fits" 2 electrons and the second fits 8, and non-ionic magnesium has 12 electrons). Then you have your electrons, which interact with incoming photons, moving between $n=3$ and higher, which leads to emission of photons of entirely different frequencies.