How does an electron absorb or emit light? It's a common understanding that atoms emit or absorb light when the energy of the photons is equal to the the difference in the energy levels in the atom. What I don't understand is how does an electron absorb light inside an atom? Is it that the atom as a whole absorbs light or the individual electrons absorb the light packets?
Also I would like to know, what does one mean when you say that an electron absorbs photon. How does an electron absorb a photon??
 A: I will leave others to comment on the detailed mechanisms involved - all of which are simply mathematical models that we use to understand the process and which can be accessed at various levels of complexity.
What is certainly true though is that an isolated electron cannot completely absorb a photon (partial absorption is possible and is known as Compton Scattering). There is just no way that both energy and momentum could be conserved in such a process. Therefore the absorption of a photon takes place in the context of the atom as a whole, where the various conservation laws can be satisfied. At its simplest it is perhaps best to think of the atom as an oscillator with discrete energy levels that can be excited or de-excited between these modes by interacting with the electromagnetic field of the light (or alternatively by absorbing or emitting the energy of the photon).
A: An atom is nothing but a bounded state of electrons and a positively charged core called nucleus. The electrons in the atom are in bound state and so their energy levels are quantized. Also, it is possible to have quantized rotational and vibrational energy levels of the molecules. The way in which they differ is in the difference in the energy characterizing the transition from one state to another.  

Possible ways in which a photon is absorbed by an atom or a molecule

If the energy level of the incoming photon is such that the electrons can have a transition from a state to some higher permissible state, then the photon energy level will be in the visible or ultraviolet range and we make use of this principle in electronic spectroscopy.
Suppose, a particular electron is in the energy state with energy eigenvalue $E_i$. There exists a higher energy level $E_f$. If the energy levels of the electron bound states are such that it precisely matches with the energy of the photon:  $h\nu=E_f-E_i$, then the electron will get excited to the energy state $E_f$.  
Now, if the incident photon energy matches the difference in the vibrational energy levels of any pair of states of the molecule, then it can cause transition from that vibrational energy state to the higher energy state. This energy usually lies in the infrared region and the technique is used in infrared spectroscopy.   
For example, in the case of diatomic molecules, the vibrational energy levels are quantized and in a good sense they can be approximated to that of a harmonic oscillator: $E_n=\left(n+\frac{1}{2}\right)\bar{h}\omega$.  So, if the photon energy is such that $h\nu=E_f-E_i$, the electron transits from the state $E_i$ to $E_f$, where $E_i$ and $E_f$ are given by the above equation of the harmonic oscillator and the states are defined by the quantum number $n=i$ and $n=f$.   
Now, if the absorption of a photon can only affect the rotational energy levels of the molecule, then the absorbed photon will be in the microwave region. The spectroscopic technique making use of this principle is the microwave spectroscopy.   
For example, the rotational energy levels of a diatomic molecule are given by: $\displaystyle{E_j=\frac{j(j+1){\bar{h}}^2}{2I}}$, where $I$ is the moment of inertia and $j$ is the angular momentum quantum number.  In such a case, we can write: $h\nu=E_f-E_i$ and the bound state absorbs the photon and will get excited to the state with energy $E_f$, with $E_f$ and $E_i$ determined by the quantum number $j=f$ and $j=i$.  
Now, the energy can be absorbed by the nuclei also. It can be elastic nuclei scattering (analog to very low energy Compton scattering by an electron. In this process, a photon interacts with a nucleon in such a manner that a photon is re-emitted with the same energy), inelastic nuclei scattering (the nucleus is raised to an excited level by absorbing a photon. The excited nucleus subsequently de-excites by emitting a photon of equal or lower energy) and Delbruck scattering (the phenomenon of photon scattering by the Coulomb field of a nucleus, also called nuclear potential scattering, which can be thought of as virtual pair production in the field of the nucleus. i.e., pair production followed by annihilation of the created pair). However, these processes are negligible in photon interactions.

Conclusion:

Absorption of a photon will occur only when the quantum energy of the photon precisely matches the energy gap between the initial and final states of the system. (the atom or a molecule as a whole) i.e., by the absorption of a photon, the system could access to some higher permissible quantum mechanical energy state. If there is no pair of energy states such that the photon energy can elevate the system from the lower to the upper energy state, then the matter will be transparent to that radiation.   
So, if any of the above types of energy transition take place, that will affect the quantum state of the system as a whole (transits the system from one state to another). So one could say, as @annav pointed out, it is the atom (or the molecule) that absorbs the radiation and changes the energy levels of its constituent particles, depending on the energy absorbed. Anyway, a change in energy level of the electron, or rotational or vibrational energy levels of the molecules can be seen as changing the quantum state of the molecule. So, it's better to stick with the concept of the molecule as a whole absorbs the energy and changes its state to some higher energy state by changing the quantum state of its constituent particles.
A: From a physical particle perspective, an electron (free or bound to an atom) cannot and does not absorb a photon. The atom absorbs the photon and takes its kinetic energy. That kinetic energy causes increased vibration of the atom which can emit another photon and/or emit a loosely held/ bound electron and/or that vibration can be transmitted to nearby atoms.  
A: The electron absorbs energy only when it exactly matches with its energy gap you can apply here conservation of momentum. The wavelength of photon matches nearly with that of electron that's why you can say that electron absorbs energy.
