MAMA: Tables
Index:
- Introduction
- How deeply are tables nested?
- TABLE element
- TD and TH elements
- TR element
- TBODY, THEAD and TFOOT elements
- CAPTION element
- COL and COLGROUP elements
Introduction
Tables have a bad reputation among the markup purists in the development community,
because many authors often use them for presentation purposes. Tables
generally increase the complexity of documents and can make them more difficult
to maintain. Authors do not really see these factors as significant drawbacks though,
judging by the overwhelming popularity of tables for layout. In practice, the use of presentation-only
tables by authors is what makes the main table-related elements some of the most
popular sub-elements of BODY
, after the A
and IMG
elements. The most frequently occurring of
these is the TABLE
element, found in 2,894,184 of MAMA's
URLs (82.47%).
Usage of the table elements
Authors have a definite preference for the table elements they use. Almost every
table uses the TABLE
, TR
and
TD
elements. All of the other elements are used rarely
by comparison. The CAPTION
, COL
,
THEAD
, COLGROUP
, and
TFOOT
elements are all used in less than 1% of
TABLE
occurrences.
ELEMENT | Frequency | ELEMENT | Frequency | |
---|---|---|---|---|
TABLE | 2,894,184 | CAPTION | 23,306 | |
TD | 2,891,972 | COL | 21,775 | |
TR | 2,891,205 | THEAD | 21,474 | |
TBODY | 364,542 | COLGROUP | 12,225 | |
TH | 148,344 | TFOOT | 3,947 |
Use of table elements together in the same page
Looking at the cases where the major table elements are used in the same
document, there are thousands of instances where they are not used together.
This is low considering the overall sample size. Keep in mind, that this
measure only counts usage anywhere in a document—not
usage together nor even correct usage. The true numbers here are likely higher
as a consequence. One wonders, for example, why a TABLE
would ever exist without any TD
or TH
elements. Leftover markup? Authoring ignorance? The plot thickens....
ELEMENTS | Frequency |
---|---|
TABLE && TR | 2,889,207 |
TABLE && (TD || TH ) | 2,892,682 |
TR && (TD || TH ) | 2,890,605 |
How deeply are tables nested?
One of the features requested for MAMA was the ability to detect deeply-nested
tables. Such structures can be excellent stress tests for a browser. In theory,
every TABLE
open tag should have a corresponding closing
tag. As MAMA traversed a document, any TABLE
open tags
added 1 to the current depth counter. A closing TABLE
tag would subtract 1 from the depth counter. When the depth counter hit a new high
score for the document, that value became the new "maximum table depth". This rather
simplistic system yielded a number for a document's "maximum table nesting depth"—it does not necessarily mean that the open and closing tags are properly nested;
that is another issue entirely. The result here may be esoteric, but can still
provide some entertainment.
The maximum nesting depth discovered was a rather astounding 745 deep at http://www.artsforeveryone.com/, with the next-nearest depth being 495 in a case where tables syntax was used very poorly. The average nesting depth when tables were used was 2.77. The full frequency table is also available.
URLs | Nesting Depth |
---|---|
http://www.artsforeveryone.com/ | 745 |
http://mikv1.narod.ru/ | 495 |
http://www.cerveceria.info/index.html | 409 |
TABLE
element
This wrapper element for table structures is (naturally) the most popular
of its type. It ranks #8 overall in element popularity, used in 82.47% of all
MAMA's URLs. Many attributes were detected for this element, only some of which
are in the standards. A few of the attributes are VERY popular
with authors—Border
, Width
,
Cellpadding
, and Cellspacing
are used in ~90% of all URLs that use tables. Other, less popular detected
attributes are either apparently bogus (such as Cool
and
Celpadding
) or editor extensions (like the numerous
Adobe GoLive attributes Gridx
/Gridy
,
Showgridx
/Showgridy
and Usegridx
/Usegridy
).
ELEMENT/Attribute | Frequency | ELEMENT/Attribute | Frequency | |
---|---|---|---|---|
TABLE | 2,894,184 | Valign | 87,291 | |
Border | 2,691,899 | Summary | 78,448 | |
Width | 2,637,117 | Bordercolorlight | 76,385 | |
Cellpadding | 2,585,020 | Bordercolordark | 73,284 | |
Cellspacing | 2,578,416 | Dir | 60,922 | |
Align | 1,226,047 | Cols | 35,703 | |
Height | 1,220,050 | Vspace | 19,771 | |
Bgcolor | 893,573 | Hspace | 19,254 | |
Bordercolor | 417,650 | Rules | 12,628 | |
Background | 281,209 | Frame | 9,945 |
The Frame
attribute
This attribute for the TABLE
element was first specified
in HTML 4.0, and its adoption rate has not been very high—MAMA only found 9,945
URLs using it (0.34% of cases using the TABLE
element).
Officially, it takes one of 9 discrete values, and, as expected, they are the most
popular ones. What never fails to surprise is how creative authors can be—MAMA
noted 70 different total values for this attribute (some of which
are listed in the full frequency table). The
top value specifies no border at all, and the next most popular is a complete
border—the main purpose of this attribute was to give authors more
control over table borders than just a simple on/off setting, but it seems that
is how authors use this attribute.
Value | Frequency | Value | Frequency | |
---|---|---|---|---|
void | 3,716 | vsides | 402 | |
box | 3,147 | above | 295 | |
border | 730 | rhs | 184 | |
hsides | 544 | lhs | 144 | |
below | 534 | 0 | 83 |
The Rules
attribute
This is a companion attribute to the Frame
attribute
covered in the previous section. The Rules
and
Frame
attributes were both introduced at the same time in HTML
4.0 and, together, were meant to give authors complex table border control. It
was discovered in 12,628 URLs (0.44% of cases using TABLE
).
As with Frame
, many values were detected in addition
to the 5 accepted values. The most popular attribute value again turns the border
off completely, and the next most popular turns it on
completely. Give authors the keys to the sports car, and they only use it to drive
to the corner grocery store.
Value | Frequency | Value | Frequency | |
---|---|---|---|---|
none | 6,134 | cols | 840 | |
all | 4,512 | groups | 426 | |
rows | 1,524 | 0 | 54 |
TD
and TH
elements
These two elements are grouped together because they mostly share the same
attributes and have very similar usage. However, their usage rates could not be more
different. The TD
element is the most popular of all the table
sub-elements, and it is the ninth most popular element overall (used in 82.41%
of all URLs in MAMA and 99.92% of all URLs using the TABLE
element). The TH
element, on the other hand, is used in only 5.13%
of URLs using the TABLE
element. Because of the
inherent attribute overlap between TD
and
TH
, it can be interesting to compare attribute usage
rates between the two elements. Percentages of the total element usage are
also provided to help with comparisons.
ELEMENT/ Attribute | Frequency | % Of Element | ELEMENT/ Attribute | Frequency | % Of Element | ELEMENT/ Attribute | Frequency | % Of Element | ||
---|---|---|---|---|---|---|---|---|---|---|
TD | 2,891,972 | -- | Rowspan | 901,303 | 31.17% | Xpos | 23,139 | 0.80% | ||
Width | 2,324,752 | 80.39% | Background | 714,706 | 24.71% | Content | 16,760 | 0.58% | ||
Valign | 2,189,287 | 75.70% | Nowrap | 353,572 | 12.23% | Scope | 8,722 | 0.30% | ||
Align | 1,977,367 | 68.37% | Bordercolor | 131,492 | 4.55% | Abbr | 2,866 | 0.10% | ||
Colspan | 1,711,437 | 59.18% | Bordercolorlight | 28,070 | 0.97% | Headers | 1,015 | 0.04% | ||
Height | 1,672,129 | 57.82% | Bordercolordark | 26,273 | 0.91% | Axis | 206 | 0.01% | ||
Bgcolor | 1,306,542 | 45.18% | Border | 24,141 | 0.83% | Charoff | 114 | 0.00% |
ELEMENT/ Attribute | Frequency | % Of Element | ELEMENT/ Attribute | Frequency | % Of Element | ELEMENT/ Attribute | Frequency | % Of Element | ||
---|---|---|---|---|---|---|---|---|---|---|
TH | 148,344 | -- | Height | 28,195 | 19.01% | Bordercolor | 3,342 | 2.25% | ||
Valign | 46,799 | 31.55% | Bgcolor | 22,406 | 15.10% | Bordercolorlight | 705 | 0.48% | ||
Width | 45,709 | 30.81% | Nowrap | 10,469 | 7.06% | Bordercolordark | 679 | 0.46% | ||
Colspan | 38,587 | 26.01% | Rowspan | 6,324 | 4.26% | Border | 149 | 0.10% | ||
Align | 35,710 | 24.07% | Background | 5,354 | 3.61% | Axis | 119 | 0.08% | ||
Scope | 30,111 | 20.30% | Abbr | 5,153 | 3.47% | Headers | 32 | 0.02% |
TR
element
This element groups table cells (TD
and
TH
elements) into rows. It was used in 2,891,205
URLs from MAMA, or 99.90% of all URLs that used the TABLE
element. Unlike its TD
and TH
sub-elements, authors appear to eschew the use of attributes for TR
-
over 60% of all the URLs that used TR
elements did
not carry attributes for any TR
instance.
ELEMENT/Attribute | Frequency | ELEMENT/Attribute | Frequency | |
---|---|---|---|---|
TR | 2,891,205 | Bordercolor | 24,073 | |
Valign | 642,250 | Background | 20,028 | |
Align | 403,805 | Border | 3,934 | |
Bgcolor | 319,779 | Bordercolordark | 557 | |
Height | 184,333 | Bordercolorlight | 539 |
TBODY
, THEAD
and
TFOOT
elements
These three elements are lumped together, but their usage varies widely. The
most popular, TBODY
, is only used in 12.60% of table
situations. The TBODY
element is almost 17 times as popular as
THEAD
, and TBODY
leaves
TFOOT
in the dust by almost a factor of 100. A number
of reasons could be found for the wide variation here, including editors being
responsible for inflating the numbers of THEAD
elements. However,
we could take the semantic meaning at face value: maybe headers for tables are
just not very popular. By the same token, one could say that even fewer authors
are inclined to use footers for their tables. With the ever-popular usage of
tables solely for layout, attaching such altruistic semantics to these elements
may be folly anyway.
It would be unfair to say that authors never use attributes with these elements, but with the most popular attribute for each achieving a mere 0.25-0.4% of the overall element usage, the numbers only get worse.
ELEMENT/Attribute | Frequency | ELEMENT/Attribute | Frequency | ELEMENT/Attribute | Frequency | ||
---|---|---|---|---|---|---|---|
TBODY | 364,542 | THEAD | 21,474 | TFOOT | 3,947 | ||
Align | 1,386 | Align | 52 | Align | 15 | ||
Valign | 1,092 | Valign | 21 | Valign | 12 | ||
Bgcolor | 405 | Bgcolor | 36 | Bgcolor | 6 |
CAPTION
element
This element is poorly used in MAMA's URL set—only 0.81% of all
TABLE
occurrences.
ELEMENT/Attribute | Frequency |
---|---|
CAPTION | 23,306 |
Align | 3,775 |
Valign | 249 |
COL
and COLGROUP
elements
As with the CAPTION
element, both of these elements
were found to have low usage rates (less than 1% of all table usages). Most
instances of the COL
element (83.76%) use the
Width
attribute, but other detected attributes for
COL
and COLGROUP
are used
in 15% of the element's instances or less.
ELEMENT/Attribute | Frequency | ELEMENT/Attribute | Frequency | |
---|---|---|---|---|
COL | 21,775 | COLGROUP | 12,225 | |
Width | 18,238 | Span | 993 | |
Span | 3,676 | Width | 869 | |
Align | 1,758 | Align | 249 | |
Valign | 1,537 | Valign | 175 | |
Height | 88 |
This article is licensed under a Creative Commons Attribution, Non Commercial - Share Alike 2.5 license.
Comments
The forum archive of this article is still available on My Opera.