A star initiates its life in the form of a gas cloud that majorly comprises helium and hydrogen. Afterwards these constituents encounter with a very weak attraction towards one another because of the force of gravity. When these cloud of gases becomes denser, the influence of gravity is to enhance the temperature and pressure. The protostellar stage is the first one in the procedure of stellar evolution and a protostar is a very immature star, which is still collecting mass from its parent molecular cloud.
A star is formed within the clouds of dust. These clouds of dust are scattered throughout the galaxy. These dust clouds are called as nebula. The turbulence inside the dust clouds rise to form knots. These knots along with sufficient mass causes gas and dust to collapse with the help of gravitational force. These sequence of steps leads to form a star.