for close objects you can use parallax, which is the same way you get depth perception from binocular vision. Only with stars, you take images about six months apart, so the distance between your “eyes” is about 2AU. Basically, how much do the foreground stars move in relation to the background stars.
For more distant objects you can either estimate based on how fast the object is moving away from us(redshift), or you can calculate based on how how much light reaches us vs how much light an object of that type is supposed to make(standard candle).
Once you know how far away something is, you know how long light took to get from there to here, because the speed of light is known.
Latest Answers