In mammals, the sex of a baby is determined by the combination of chromosomes it inherits from its parents.
X And Y Chromosomes
Nearly every cell in a male body has two different sex chromosomes–one is shaped like an X and one is shaped like a Y.
Females also have two sex chromosomes in each cell but they are both X-shaped.
When the male sperm and the female egg come together, each one contributes one sex chromosome. The female always contributes an X chromosome while the male can provide either an X or a Y.
If the male provides an X then the embryo has two X chromosomes and becomes a female. If the male provides a Y then the embryo has one of each and grows into a male.
Differences Among The Animal Kingdom
But what’s true for mammals isn’t always true for the rest of the animal kingdom. The sex of baby birds is also determined by two different sex chromosomes, but in birds, it’s the male that has two of the same-shaped sex chromosomes and the female that has two different sex chromosomes.
A lot of reptiles, including crocodiles and some turtles don’t even have sex chromosomes. The sex of these animals is determined by the temperature of the eggs before they hatch.
And in some species of fish, female adults can turn into males if there aren’t enough males in the population, while in others males turn into females.