Photosynthesis is the process by which chlorophyll-containing cells produce carbohydrates from carbon dioxide and water using energy from sunlight. During photosynthesis, carbon dioxide and water are converted into glucose and oxygen using light energy captured by chlorophyll. The key structures and functions of leaves that facilitate photosynthesis include stomata for gas exchange, veins for transport, palisade mesophyll containing many chloroplasts for photosynthesis, and spongy mesophyll for gas diffusion. Plants have adapted traits like stomata distribution and chloroplast placement to optimize photosynthesis according to their habitat.