A star is a huge mass of matter, that is held together by gravity.
Stars are created within clouds of gas and dust, called nebulas. Made mostly of hydrogen gas, some kind of disturbance in the force causes areas to clump together and gravity causes the gas and dust to collapse in on themselves.As the cloud condenses, it also begins to spin and that makes it start to flatten out on the edges.
The cloud’s matter begins to heat up as it contracts smaller and smaller, under the force of its gravity. As the cloud condenses, it becomes denser, more tightly packed in, and this makes it heat up.
At this point, it has a center region and clumps of matter orbiting around it. But it is not yet burning or giving off light. It is a Protostar, kind of like a “pre-star”.
When the gases become hot enough, about 10 million °Kelvin (18 million °F), hydrogen begins to fuse together into helium nuclei, and the star is born. Energy from nuclear fusion pushes outward from the center of the star and stops the collapse.
Nuclear energy “E” is created when hydrogen atoms are smashed together at a very high speed and make a helium atom, the difference in the mass “M” (between the old hydrogens atoms and new helium atoms), becomes the energy produced.
The star is in equilibrium, the force pulling inward (gravity) is equal to the force pushing outward (nuclear fusion).