The star begins as a stellar nebulae. This is a dense cloud of gas and dust containing hydrogen and helium. As it is under a large amount of gravitational pressure, this nebula will then collapse under gravity and heat up. This occurs due to the conversion of gravitational potential energy to thermal kinetic energy. This collapse results in a disc shaped clump of matter with the centre of gravity focused at the core. This is known as a protostar. Some of the interstellar dust can be ejected during this process. Once the protostar has formed, the dust in the surrounding disc can clump to form planets and often moons. This forms a pre-main sequence star. Eventually, the gravitational pressure will become sufficient to then allow fusion to occur. During this process, hydrogen nuclei convert to helium nuclei resulting in an overall release of a large amount of energy. The star then becomes stable as the outwards push force from nuclear fusion is in equilibrium with the inwards pull force from gravity. This then forms the main sequence star.