Environmental heterogeneity may be a general explanation for both the quantity of genetic variation in populations and the ecological niche width of individuals. To evaluate this hypothesis, I review the literature on selection experiments in heterogeneous environments. The niche width usually – but not invariably – evolves to match the amount of environmental variation, specialists evolving in homogeneous environments and generalists evolving in heterogeneous environments. The genetics of niche width are more complex than has previously been recognized, particularly with respect to the magnitude of costs of adaptation and the putative constraints on the evolution of generalists. Genetic variation in fitness is more readily maintained in heterogeneous environments than in homogeneous environments and this diversity is often stably maintained through negative frequency-dependent selection. Moreover environmental heterogeneity appears to be a plausible mechanism for at least two well-known patterns of species diversity at the landscape scale. I conclude that environmental heterogeneity is a plausible and possibly very general explanation for diversity across the range of scales from individuals to landscapes.