Ok so there are 22 pairs of chromosomes in a cell plus the sex chromosome (so in total, there are 23 pairs of chromosomes).
The sex chromosome must contain either XX or XY (if it's XXY, XYY etc. then it's shows abnormality)
XX means female
XY means male
During fertilization, the female egg cell contains X chromosome, and it depends on the sperm what chromosome it'll give, either X or Y. If it gives X then it's a female. If it's Y then it's a male.