for very distant objects these stars themselves are too faint to be visible, but if you look at clusters of galaxies, we find that the very brightest galaxy in a cluster is the same brightness in all clusters and so the fainter it looks to us the further away the cluster of galaxies must be.