The feces of most vegetarian mammals are greenish, due to the plant's green pigment called chlorophyll, which cannot be digested. Birds' feces are whitish, as they are covered in dry urine, made of white uric salts. When carnivores eat bones, their feces can result whitish due to the mineral salts from the bones which are not absorbed.
Human fecal matter varies significantly in appearance, depending on diet and health. Normally it is brown, semisolid, with a mucus coating. A proportion of ¾ is formed by water and the rest of the solid material consists of dead and live bacteria (and, in some cases, also gut parasites, adults, larvae and eggs), mineral compounds, undigested organic chemicals (especially cellulose, some fat and proteins) and compounds from the digestive juices. All these wastes bring their own contribution to coloring the excrements.
But their brown color is due to bile, stercobilin and urobilin, all released by liver.
The last two compounds are derived from the bilirubin, resulted from the breakdown of the hemoglobin, the red pigment of the blood's red cells (involved in transporting oxygen and carbon dioxide in the blood), a process occurring with the death of these cells. Without these chemicals, the feces would have the color of a vomit.
In newborn babies, fecal matter is yellow/green after the meconium (materials ingested during the time the infant spends in the womb: intestinal epithelial cells, lanugo, mucus, amniotic fluid, bile and water) is eliminated and this is due to the presence of bile alone.
When the body starts producing bilirubin from dead red blood cells, it gets the brown appearance, unless the baby is breastfed, and in this case it remains soft, pale yellowish, and not unpleasantly scented until the baby starts ingesting significant quantities of other food.
But an individual can experience many types of feces. A "green" stool is from a rapid transit of plant materials through the intestines (or the intake of certain blue or green food colorants), and "clay-like" look (light color) means no bilirubin.
Meat-based diets (meat is extremely rich in iron, which boosts the synthesis of hemoglobin, whose molecule contains iron) can darken the feces as more bilirubin is produced.
A severe diarrhea can blacken the stool due to the black digested blood coming from an intestine injury, whereas red streaks of blood in stool point out bleeding in the rectum or anus.
Food may sometimes appear in the feces, the most common undigested food items visible in human feces being seeds, nuts, corn and beans, due to their high amount of cellulose fibers, which cannot be attacked by the human digestive juices.