The Sun, or any star for that matter, “shines” or “burns” due to a process of thermonuclear fusion, not due to a chemical reaction like the oxygen-driven fires on Earth.
Because the Sun is so massive, it has great gravity and so its core is under tremendous levels of pressure and heat. This pressure and heat is so high in the Sun’s core (about 15 million °C) that the protons of the hydrogen atoms which largely make up the Sun collide into each other with enough speed that they stick together or “fuse” to create helium nuclei. It effectively takes four hydrogen nuclei to fuse together to produce one nucleus of helium, although it is actually a more complicated three-part process (hydrogen to deuterium, deuterium to helium-3 and helium-3 to helium).
However, the net mass of the fused helium nuclei is actually slightly smaller than the sum of the masses of its constituent hydrogen atoms, and this tiny amount of lost mass is converted into an enormous amount of energy, according to the mass-energy equivalence relationship E = mc². To give an idea of the scale of this process, each second of every day our Sun converts about 700 million tons of hydrogen into about 695 million tons of helium. The missing 5 million tons is converted into energy equivalent to the detonation of about 100 billion one-megaton bombs, two hundred million times the explosive yield of every nuclear weapon ever detonated on Earth. And this happens every second.
The fusion process therefore releases huge amounts of energy, initially as gamma ray photons, that traverse the interior of the Sun through a combination of radiation and convection, and are then radiated into space as electromagnetic energy, including visible light. The process also emits particle radiation, known as the “stellar wind”, a steady stream of electrically charged particles, such as free protons, alpha particles and beta particles, as well as a steady stream of neutrinos. It is the internal pressure of this nuclear fusion process that prevents the Sun from collapsing further under its own gravity (known as a state of hydrostatic equilibrium).
Hydrogen is by far the most common element in the Sun (and in the universe as a whole) and helium is the second most common. A star will spend most of its life, called the “main sequence” phase, fusing hydrogen into helium, but, in larger hotter stars, the helium which accumulates in the core becomes more and more compressed and hot until the helium atoms begin fusing to form oxygen and carbon. These stars are therefore continually creating heavier elements from the less heavy: helium from hydrogen, oxygen from helium, and so on and so on. Even in the largest of stars, however, this process stops at the ultra-stable element iron, which will not easily fuse to form heavier elements, at which point the inward pressure of gravity takes over, crushing the core and resulting in a supernova explosion and the creation of a neutron star or black hole.