Back when cotton was cotton (e.i. pure), it was safe to bleach almost all whites. Nowadays, fabrics are more complicated: many have built-in optical brighteners that enhance whiteness but turn the fabric yellow if its expose to bleach or even strong sunlight.
How do you know if brighteners have been added? The care label won’t tell you, but if it says “no chlorine bleach,” that’s usually a giveaway. In those cases, be sure to launder as instructed. For whites that are washable, treat fresh spills by quickly soaking them under cold running water while rubbing the spot with your fingers, then launder. Heat causes yellowing on some optically enhance whites, so air-dry if label says “no chlorine bleach.”
You may be interested in the following related articles as well.

