A pigment called chlorophyll is responsible for the ability of plants to produce their own food. This pigment has the ability to absorb energy from sunlight and the energy absorbed is used to carry out an endothermic reaction that results in the conversion of water and carbon dioxide into carbohydrates. Carbohydrates are the food of plants and during respiration produce energy required for cellular processes.
2n CO2 + 2n H2O --> 2(CH2O)n + 2n O2
Chlorophyll is found in plant structures called chloroplasts which are primarily present in their leaves. As chlorophyll is green in color it leads to the green color of leaves.
Chlorophyll is made up of the elements magnesium, oxygen, hydrogen and carbon. The chemical structure of chlorophyll can be found at this link.