A solar eclipse happens when the moon passes in front of the Sun and casts a shadow on the Earth.
This is because the distance between the Sun and the Earth is about 400 times the Moon’s distance from the Sun. The Sun’s diameter is also about 400 times larger than the Moon’s.
Due to these measurements, the Sun and the Moon have a similar size when viewed from Earth. When the moon passes in front of the sun, it blocks the light from reaching Earth.