Forget what you learned in science class about white being a non-color. Your teacher wasn't talking about fabrics.
When your underwear grays and your bath sheets turn yellow, you'll know that white is - was - a color.In their natural state, many fabrics have an off-white or yellowish cast and are bleached to remove that color. Manufacturers also often add optical brighteners which make fabrics appear whiter and brighter. Occasionally these agents break down, causing the fabric to revert to its natural off-white or yellowish hue.
Exposure to light can break down fluorescent brighteners, causing areas not exposed to be unaffected. Thus, the front of a sweater laid out to dry in the sun may turn yellow while the back remains white. Once this happens, it usually can't be corrected.
Graying is another story. Dingy-looking whites are most often caused by incomplete soil removal over a long period of time despite repeated washings. According to the International Fabricare Institute, this can be caused by failing to pre-soak heavily stained garments; using too little detergent; overloading the washing machine; using water that isn't hot enough, or sorting clothes incorrectly.
To remove this soil buildup and restore whiteness to washable items, use the hottest water temperature acceptable for the fabric, add 1 to 2 cups of water conditioner, add detergent, add clothes and run through a complete wash and rinse cycle.