The sun is almost entirely composed of hydrogen and helium. Hydrogen accounts for about 75 percent of the sun's mass, with the other 25 percent being almost entirely helium. Other elements, such as oxygen and carbon, do exist in the sun, but at such low concentrations as to be insignificant.
Helium was first detected in the sun, which is why the element was called "helium," after Helios, the sun god in Greek mythology. Helium is present as a by-product of the sun's nuclear processes. The hydrogen that makes up the bulk of the sun's composition is very hot and exists in an excited phase of matter known as plasma.
Under less energetic conditions, hydrogen atoms encounter and repel each other in a weak fashion. In the crushing pressure and blazing heat of the sun's core, however, the hydrogen atoms aren't able to bump off each other, so they strike and stick together with sufficient force to form a new, heavier atom. This process, known as fusion, releases the energy that eventually pours out of the sun and has gradually been converting the giant star's hydrogen into helium for the last several billion years.
Despite the fact that a quarter of its mass has already been converted into helium, the sun still has enough fuel to burn for a long time. The existing store of hydrogen is sufficient to keep sun burning for at least another 5 billion years.