In the chloroplast, both types are associated with integral membrane proteins in the thylakoid membrane.
Note the system of alternating single and double bonds (white bars) that run around the porphyrin ring. Although I am forced to draw the single and double bonds in fixed positions, actually the "extra" electrons responsible for the double bonds are not fixed between any particular pair of carbon atoms but instead are free to migrate around the ring. This property enables these molecules to absorb light.Both chlorophylls absorb light most strongly in the red and violet parts of the spectrum. Green light is absorbed poorly. Thus when white light shines on chlorophyll-containing structures like leaves, green light is transmitted and reflected and the structures appear green.
Chloroplasts also contain carotenoids. These are also pigments with colors ranging from red to yellow.
Carotenoids absorb light most strongly in the blue portion of the spectrum. They thus enable the chloroplast to trap a larger fraction of the radiant energy falling on it.
Carotenoids are often the major pigments in flowers and fruits. The red of a ripe tomato and the orange of a carrot are produced by their carotenoids.
In leaves, the carotenoids are usually masked by the chlorophylls. In the autumn, as the quantity of chlorophyll in the leaf declines, the carotenoids become visible and produce the yellows and reds of autumn foliage.
The figure below shows the structure of beta-carotene, one of the most abundant carotenoids. Note again the system of alternating single and double bonds that in this molecule runs along the hydrocarbon chain that connects the two benzene rings. As in chlorophyll, the electrons of the double bonds actually migrate though the chain and also make this molecule an efficient absorber of light.
Many animals use ingested beta-carotene as a precursor for the synthesis of vitamin A.