They are visible because of starlight either within them or behind that.
As for how the stars got there, you probably know that nebulae are where stars are born. Nebulae are clouds of gas/dust pulled together by gravity over an immensely long time. As gravity pulls the gas closer together, the gas at the outside presses more and more on the gas in the centre.
Eventually, if there’s enough gas in the cloud, the pressure at the centre will be so great that two hydrogen atoms will fuse together into a helium atom. Fusion emits a huge amount of energy, which triggers other hydrogen atoms to fuse together. This causes a chain reaction, fusing huge amount of hydrogen and emitting huge amount of heat/light.
That’s all a star is: a cloud of dust that got so big it started fusing together, releasing energy.
Latest Answers