If you have only a little melanin, you have white skin. If you have very black skin, it is because your skin makes a lot of melanin. Brown skin comes from all the variations you can get between white and black. If you are Chinese, your skin is slightly thicker which gives your skin a yellowish shade. No matter the color, it all comes from melanin.
Melanin is produced by cells called melanocytes.
It is produced to protect the skin from the harmful ultraviolet rays of the sun. Even dark skinned people can get a sunburn, making their skin even darker. Take away the sun and their skin color returns to the original shade. To understand how this can happen, let's take a very basic course in genetics. Genes in the DNA carry the instructions on how to make each and every feature that makes your body.