Stars form from collapsing clouds of gas and dust.
As the cloud collapses, its density and temperature increase. The temperature and density are highest at the center of the cloud, where a new star will eventually form. The object that is formed at the center of the collapsing cloud and which will become a star is called a protostar. Since a protostar is embedded in a cloud of gas and dust, it is difficult to detect in visible light. Any visible light that it does emit is absorbed by the material surrounding it.