The unique genetic code that a baby inherits from both parents contains protein which enables melanin to be produced in his or her hair. The amount of melanin determines whether the child has light or dark hair and the color usually remains within the color range of its parents' hair.
From the 46 chromosomes that all human beings have, a baby inherits 23 chromosomes from the mother and the same number from the father. These two put together contain between 60,000 and 100,000 genes. Some of these genes are dominant and a few are recessive. The protein contained in the genes produces melanin of two types - eumelanin and pheomelanin. Larger concentrations of eumelanin produces dark hair ranging from brown to black shades and pheomelanin causes lighter hair shades ranging from blond to red.
Dark hair is the dominant gene in most people. Parents with the exact same shade of hair or those with different shades, can have a baby with hair that is a different color but in the same shade range. However, it is also possible for a dark haired parent with a blond recessive gene to have a blond baby if the other parent also has a blond gene. So a baby's hair color can fall anywhere in the shade range of the parents' hair or be entirely different if one or both of them has a different recessive gene.