An egg contains either X or Y chromosome and a sperm contains X chromosome.
A sperm either contributes an X or a Y chromosome. The female always contributes an X chromosome. Hence, if the sperm contributes X chromosome, the resulting offspring is a female and if it contributes Y chromosomes, the resulting offspring is a male.