A star starts out as an enormous cloud of gas and dust many light-years across. Star formation begins when the cloud begins to condense under its own gravity. The processes that initiate this contraction are not fully understood. The cloud fragments fuse into stellar mass clouds known as protostars. Protostars do not emit visible light, but glow weakly in the infra-red region of the spectrum and can be detected in Bok Globules. If the mass of a protostar is too small, nothing interesting happens, and it dies away as a brown dwarf. If it is massive enough, however, enough gas and dust eventually collects into a giant ball that, at the center of the ball, the temperature (from all the gas and dust bumping into each other under the great pressure of the surrounding material) reaches about 15 million kelvins (or 15 million degrees Celsius). At this point, nuclear fusion begins and the ball of gas and dust starts to glow. A new star has begun its life in our Universe. T Tauri stars are an example of stars in this early stage of life.
Depending on the star mass, the star will place itself on a specific point of the main sequence of the H-R diagram. It will rest there for a period of millions (for the biggest and hottest starts) to billions (for mid-sized stars like the Sun) to tens of billions (for red dwarf stars) of years, using most of the hydrogen in its core.
What happens inside the star is as follows: As the contraction of the gas and dust progresses and the temperature reaches 15 million degrees or so, the pressure at the center of the ball becomes enormous. The electrons are stripped off of their parent atoms, creating a plasma. The contraction continues and the nuclei in the plasma start moving faster and faster. Eventually, they approach each other so fast that they overcome the electrical repulsion that exists between their protons. Hydrogen nuclei are fused to form helium in the proton-proton chain or by the CNO cycle. In doing so, they give off a great deal of energy. This energy from fusion pours out from the core, setting up an outward pressure in the gas around it that balances the inward pull of gravity. When the released energy reaches the outer layers of the ball of gas and dust, it moves off into space in the form of electromagnetic radiation. The ball, now a star, begins to shine.
New stars come in a variety of sizes and colors. They range from blue to red, from less than half the size of our Sun to over 20 times the Sun's size. It all depends on how much gas and dust is collected during the star's formation. The color of the star depends on the surface temperature of the star. And its temperature depends, again, on how much gas and dust were accumulated during formation. The more mass a star starts out with, the brighter and hotter it will be. For a star, everything depends on its mass.
Throughout their lives, stars fight the inward pull of the force of gravity. It is only the outward pressure created by the nuclear reactions pushing away from the star's core that keeps the star "intact". But these nuclear reactions require fuel, in particular hydrogen. Eventually the supply of hydrogen runs out and the star begins its demise.
After millions to billions of years, depending on their initial masses, stars run out of their main fuel - hydrogen. Once the ready supply of hydrogen in the core is gone, nuclear processes occurring there cease. Without the outward pressure generated from these reactions to counteract the force of gravity, the outer layers of the star begin to collapse inward toward the core. Just as during formation, when the material contracts, the temperature and pressure increase. This will force helium fusion in the core. The newly generated heat temporarily counteracts the force of gravity, and the outer layers of the star are now pushed outward. The star expands to larger than it ever was during its lifetime -- a few to about a hundred times bigger. The star has become a red giant.
What happens next in the life of a star depends on its initial mass. Whether it was a "massive" star (some 5 or more times the mass of our Sun) or whether it was a "low or medium mass" star (about 0.4 to 3.4 times the mass of our Sun), the next steps after the red giant phase are very, very different.
Once a medium size star (such as our Sun) has reached the red giant phase, its outer layers continue to expand, the core contracts inward, and helium atoms in the core fuse together to form carbon. This fusion releases energy and the star gets a temporary reprieve. However, in a Sun-sized star, this process might only take a few minutes! The atomic structure of carbon is too strong to be further compressed by the mass of the surrounding material. The core is stabilized and the end is near.
The star will now begin to shed its outer layers as a diffuse cloud called a planetary nebula. Eventually, only about 20% of the star's initial mass remains and the star spends the rest of its days cooling and shrinking until it is only a few thousand miles in diameter. It has become a white dwarf. White dwarfs are stable because the inward pull of gravity is balanced by the degeneracy pressure of the star's electrons. This should not be confused with the electrical repulsion of electrons, but is a consequence of the Pauli exclusion principle. With no fuel left to burn, the hot star radiates its remaining heat into the coldness of space for many millions of years. In the end, it will just sit in space as a cold dark mass sometimes referred to as a black dwarf. The universe is not old enough for any black dwarf stars to exist yet.
Fate has something very different, and very dramatic, in store for stars which are some 5 or more times as massive as our Sun. After the outer layers of the star have swollen into a red supergiant (i.e., a very big red giant), the core begins to yield to gravity and starts to shrink. As it shrinks, it grows hotter and denser, and a new series of nuclear reactions begin to occur, temporarily halting the collapse of the core. Then silicon fuses to iron-56. Up until now, all these fusion reactions had liberated energy. However, fusing iron does not liberate energy - because of the vast pressure and temperature, iron is actually forced to fuse. The supernova explosion is less than a fraction of a second away. Iron takes in energy when it fuses, it also takes in electrons. This energy and those electrons had been helping to support the star against it's own gravity. Now, with the support gone, the envelope of the star comes crashing down onto the core at a fine fraction of the speed of light. The implosion rebounds into a shock wave going through the star.
As the shock encounters material in the star's outer layers, the material is heated to billions of degrees, fusing to form the heavier elements. Indeed, all elements heavier than iron-56 are formed in supernovae explosions. In one of the most spectacular events in the Universe, the shock propels the material away from the star in a tremendous explosion called a supernova. The material spews off into interstellar space -- perhaps to collide with other cosmic debris and form new stars, perhaps to form planets and moons, perhaps to act as the seeds for an infinite variety of living things.
So what, if anything, remains of the core of the original star? Because we do not have a good understanding of the actual explosion mechanism, it is not entirely clear. It is known that in some supernovae, the intense gravity inside the supergiant causes the electrons to be forced inside of (or combined with) the protons, forming neutrons. In fact, the whole core of the star becomes nothing but a dense ball of neutrons, giving birth to a compact object called a neutron star.
However, it is still an open question whether or not all supernovae do form neutron stars. It is also believed that if the stellar mass is high enough the star will collapse into a black hole. However, our understanding of stellar collapse is not good enough to know whether it is possible to collapse directly to a black hole without a supernova, if there are supernovae which then form black holes, or what the exact relationship is between the initial mass of the star and the final object that remains.