What causes certain LEGO parts to yellow over time, and how can this be prevented? I've noticed that certain LEGO colors have a tendency to turn yellow over time. For example, I have a set of 4 "white" wheel hubs that are all now various shades of yellow:



I know there is already some information on how to fix this, but I'd like to understand why this happened and how to avoid it. What causes LEGO parts to turn yellow, and what specific steps can be taken to prevent this damage?
There are many things such as dirt and chemicals that can cause elements to change color. Dirt can easily be washed off, but certain contaminants such as cigarette smoke can stain plastic.

The most common issue that causes LEGO bricks to yellow is interaction with ultraviolet light, most commonly from the sun. The simplest way to prevent this is to store parts indoors out of the way of even indirect sunlight.

There are some tips for correcting this issue in another question, and more details about the chemical process that causes UV light to degrade ABS over on Chemistry.