Stars burn at tens of thousands of degrees Fahrenheit, yet in an amazing paradox, are created by cooling gas.
Here’s how it works: stars are created in giant clouds of interstellar gas made up of mostly hydrogen (number one on perodic table). As the gas cools it collapses and gains more and more density. At some point the mass and density is so great that the pressure of gravity causes nuclear fusion – hydrogen fuses into helium. Literally, hydrogen atoms collide together with such great force due to gravity that fusion is the result. Then the star achieves an equilibrium where the immense gravity from the star’s great mass presses inward and the great energy of the fusion of hydrogen into helium presses outward (also, some helium is also converted into heavier elements as well).
After hundreds of millions (for really big stars) or billions (for medium and small stars) of years the hydrogen is depleted to the point that nuclear fusion slows down. Gravity begins to win the battle and the star compresses. This results in greater heat and greater gravity as more mass is in less space. Fusion starts over again, this time helium is the main fuel as it converts to carbon and oxygen. This doesn’t last nearly as long, but is more intense and at greater heat. The intensity of the stars brightness increases exponentially and fusion starts winning the battle with gravity and the star expands into a red giant. When our star, the sun, becomes a red giant in about 4.5 billion years it will expand out to encompass Mercury, Venus and the Earth. At this point stars collapse. Depending on the mass of the collapsing star, a number of different things can occur at this point.
Note – the above image is of a star nursery. Stars are being born in the red ring.