This is somewhat subjective, but here are a few reasons you might want to do that.
There is no standard background color for a page, even though pretty much all browsers will use white. It is generally a good idea not to rely too heavily on defaults in case they change. While it is unlikely that this specific case will change, some people will avoid exceptions and never rely on defaults. EDITED: Modern Firefox actually lets you pick the default color for pages. I'm now using it to view markdown-generated HTML1 files and text files in white-on-black. So a site not specifying background color but specifying text color would be black on black for me.
Also, as the Zen of Python says: explicit is better than implicit. Whether you agree or disagree is up to you. When I look at the CSS for the html and body elements, I like seeing background
. It makes it obvious. I don't have to ask myself if there's another place where the background might be set. But then again, this is subjective. Others will say it makes the code longer to read for no reason.
A much more plausible explanation is that big websites tend to use another language to make their stylesheets and then compile them to CSS. They use variables for most colors so that the palette can be easily altered without having to search and replace the color values everywhere manually. They'll extract the site's background color to a variable as well. I do that very often, but the result is that if I settle for a white background, the compiled CSS will include background: #fff;
. Why specifically #fff
? Because the compiler prefers using as little characters as possible to represent a color, and white
would be longer.