Stars go through many stages while forming. The stages can take anywhere between hundreds of thousands of years to millions of years. The amount of time that it takes to form a star depends on the mass of the star forming. Very massive stars will take less time to form while stars that are smaller will take more time to form.
Stars begin their lives in molecular clouds. Molecular clouds are often referred to as a star's nursery because they are were stars begin their lives. Molecular clouds are very dense clouds that are dense enough to allow the formation of molecules. The most common molecule found in molecular clouds is Hydrogen. Hydrogen is the most abundant element in the Universe. It makes up about 75% of all ordinary matter found in the universe.
Molecular clouds are so dense that turbulence and fluctuations within them cause certain amounts of matter to join together. After this matter joins together, the dust and gas in this portion of the cloud begins to collapse under its own gravity. While it collapses the matter near its center get hotter and hotter. This core is known as a protostar. A protostar is the stage before a star begins nuclear fusion. This matter is known as a star only when it begins nuclear fusion.
Here is an image of a molecular cloud: