Web Authoring Statistics: The body element

The body element is quite the abused element:

bgcolor, topmargin, leftmargin, marginheight, marginwidth, link, text, vlink, alink, onload, background, rightmargin, bottommargin, style, class, id, bgproperties, lang, onunload, and oncontextmenu.

Of the top twenty most-used attributes on body, fourteen are purely presentational. Of the remaining six, three are event handlers; of these, onload is the most common by a significant margin; then we have onunload and oncontextmenu, both used on a small fraction of the pages in the sample. One area of future study would be to see what these attributes are used for: is onunload used mostly by Web applications for legitimate purposes, or is it used more by hostile sites to show pop-unders? Is oncontextmenu used for good purposes, or to cancel the showing of the context menu?

The last three attributes are class (probably used for presentational hooks), id (probably used for either scripting or CSS signatures), and lang (which is not used often; it seems it is much more frequently used on the html element — a good thing, since there it also catches the metadata in the head).

The presentational attributes provide us with some interesting insights. For example, the four IE-specific margin attributes (topmargin, rightmargin, bottommargin, and leftmargin) are not all specified the same number of times. People care about the top margin most of all, then about the left margin, then the right margin, and then the bottom margin. This is borne out by the Netscape-specific margin attributes, which are in the same order: marginheight first, then marginwidth.

Another insight is that browsers really should stop letting users set default values (as opposed to overrides) for text and background colors: at least half the pages that specify a background color omit to specify a text color, opening up the potential for color clashes. On the subject of colors, we also find that people set the text, unvisited link, and visited link colors much more often than they set the active link color — not that surprising, but we were expecting a much bigger difference between the number of pages that set the visited link color and set the unvisited link color.

One conclusion one can draw from the spread of attributes used on the body element is that authors don't care about what the specifications say. Of these top twenty attributes, nine are completely invalid, and five have been deprecated for nearly eight years, half the lifetime of the Web so far.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.