This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 12413 - Handling of <table border=0> is incompatible with the Web
Summary: Handling of <table border=0> is incompatible with the Web
Status: CLOSED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://dev.w3.org/html5/spec/renderin...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-04 10:50 UTC by Leif Halvard Silli
Modified: 2011-08-10 19:52 UTC (History)
10 users (show)

See Also:


Attachments

Description Leif Halvard Silli 2011-04-04 10:50:23 UTC
(Relates to ISSUE-155/Bug 7468 - not sure if it shoudl be described as "depends on".)

ISSUE-155 does not try to change HTML5's Rendering section w.r.t. <table>. However, while working with ISSUE-155, it become clear that HTML5 is out of tune with the Web even rendering wise: As <table border="0"> is frequently used on existing layout tables,  HTML5's Rendering section is simply  incompatible with the Web when it suggest to render any table with the @border attribute present (even when its value is "0") with a 1px border.

This is HTML5's style rule for tables with the border attribute: http://dev.w3.org/html5/spec/rendering.html#decohints

table[border] > tr > td, table[border] > tr > th,
table[border] > thead > tr > td, table[border] > thead > tr > th,
table[border] > tbody > tr > td, table[border] > tbody > tr > th,
table[border] > tfoot > tr > td, table[border] > tfoot > tr > th {
  border-width: 1px;
}

Effectively, this means that  <table border="0"> is to be treated as <table border="1">.

Use agents: no user agents treats border="0" like that. (Tested in: Webkit [current last version], Opera 11, Firefox 4)

History - HTML4: 
  * HTML4 says that table@border with an empty value (border="") or a non-digital value (border="border") for compatibility reasons should be treated like border="1". And except for a few bugs, user agents do follow HTML4: empty @border and @border="border" *is* equal to border="1". Thus HTML5 is not incompatible with whether user agents nor *this* part of of HTML4.
  * However, HTML4 does also say that border="0" is equal to not using the @border attribute at all.  And not only HTML4, but also the "real Web"  (user agents and Web authors) do treat border="0" as equal to no @border attribute. THus, HTML5 deviates from "the Web" when it suggest to see border=0 as border=1.

Examples of layout tables in the wild which contains border="0",  easily found via Google: 

 * http://www.ist-inc.com 
 * Any layout-table based Web page produced by Freeway  
    (http://www.softpress.com), including the 2011 release
    (Freeway has a table layout mode in addition to "normal" mode.)
 * http://wiki.services.openoffice.org/wiki/Documentation/
 * http://wiki.services.openoffice.org/wiki/Documentation/OOoAuthors_User_Manual/Writer_Guide/Using_tables_for_page_layout
 * http://www.linuxquestions.org/
 * http://www.shire.net/learnwebdesign/nocss/tables1.htm
 * http://www.at.ufl.edu/_archive/accessibility_cd/AccWeb/tables/layout_tables.html
 * http://www.thewebseye.com/using-tables.htm

Tutorials of layout tables are probably few, since it is a frown-upon thing, but those pages who explain it, often suggest user of border="0":

 * http://www.w3schools.com/html/html_layout.asp
 * http://html.cita.illinois.edu/style/layout/layout-example.php
 * http://www.quackit.com/html/tutorial/html_layouts.cfm
 * http://www.shire.net/learnwebdesign/nocss/tables1.htm
 * http://www.thewebseye.com/using-tables.htm

Proposed fix of HTML5:  Simply add one more style rule for border="0", after the current style rule:

table[border=0] > tr > td, table[border=0] > tr > th,
table[border=0] > thead > tr > td, table[border=0] > thead > tr > th,
table[border=0] > tbody > tr > td, table[border=0] > tbody > tr > th,
table[border=0] > tfoot > tr > td, table[border=0] > tfoot > tr > th {
  border-width: 0;
}
Comment 1 James Graham 2011-04-04 11:07:22 UTC
From the spec:

"The table element's border attribute maps to the pixel length properties 'border-top-width', 'border-right-width', 'border-bottom-width', 'border-left-width' on the element. If the attribute is present but parsing the attribute's value using the rules for parsing non-negative integers generates an error, a default value of 1px is expected to be used for that property instead."

i.e. border=0 maps to border-width:0 already.
Comment 2 Leif Halvard Silli 2011-04-04 11:46:06 UTC
(In reply to comment #1)
> From the spec:
> 
> "The table element's border attribute maps to the pixel length properties
> 'border-top-width', 'border-right-width', 'border-bottom-width',
> 'border-left-width' on the element. If the attribute is present but parsing the
> attribute's value using the rules for parsing non-negative integers generates
> an error, a default value of 1px is expected to be used for that property
> instead."
> 
> i.e. border=0 maps to border-width:0 already.

Firstly: Anyone that can parse HTML5's CSS rules - see quote above - can see that
 table[border] td{border-width:0} results in a 0 - zero - pixel border for the table *cells*, regardless of the value or @border.

Secondly, you seem to repeat what Aryeh has already remarked:
http://lists.w3.org/Archives/Public/public-html/2011Mar/0616.html
Namely, you [or more correctly, the spec text you quoted] speak about the borders on the very <table> container element.

But otherwise, it is a very good point you have that <table border="0"> results in <table style="border-width:0">. The question then becomes: why does it not, as this bug report suggests, also result in <td style="border-width:0"> and <th style="border-width:0">?
Comment 3 Aryeh Gregor 2011-04-04 14:16:31 UTC
(In reply to comment #1)
> From the spec:
> 
> "The table element's border attribute maps to the pixel length properties
> 'border-top-width', 'border-right-width', 'border-bottom-width',
> 'border-left-width' on the element. If the attribute is present but parsing the
> attribute's value using the rules for parsing non-negative integers generates
> an error, a default value of 1px is expected to be used for that property
> instead."
> 
> i.e. border=0 maps to border-width:0 already.

That's what I thought originally, but Leif is right.  Consider this:

data:text/html,<!doctype html>
<table border=15><td>A<td>B</table>
<table border=0><td>A<td>B</table>

The spec says that the first table should have a 15px border and the second no border, which is correct.  But it says that both of them should have 1px borders on each cell, which is wrong for the latter table.
Comment 4 Boris Zbarsky 2011-04-04 21:35:07 UTC
For what it's worth, you can't do the desired thing here with CSS.  Gecko implemented a custom pseudo-class called :-moz-table-border-nonzero to match tables with a border attribute set.  For example, border=" 0 " needs to be treated just like border="0", and there's no way to do that in CSS.
Comment 5 Leif Halvard Silli 2011-04-05 01:39:13 UTC
(In reply to comment #4)
> For what it's worth, you can't do the desired thing here with CSS.  Gecko
> implemented a custom pseudo-class called :-moz-table-border-nonzero to match
> tables with a border attribute set.  For example, border=" 0 " needs to be
> treated just like border="0", and there's no way to do that in CSS.

My proposal is that @border should be defined like a normal, enumerated attribute:

<table border="1"> = border-width:1px; Valid keyword value 
<table border=""  > = border-width:1px; Valid keyword value
<table border="9"> = border-width:1px; Invalid value default
<table border="0"> = border-width:0; Valid keyword value
<table no-border > = border-width:0; Missing value default 

It is pretty obvious that when a style should be derived from an enumerated attribute, then "you can do the desired thing with CSS", alone.
Comment 6 Leif Halvard Silli 2011-04-05 02:09:37 UTC
(In reply to comment #5)

> It is pretty obvious that when a style should be derived from an enumerated
> attribute, then "you can do the desired thing with CSS", alone.

Err ... That was meant to be "then you _can't_ do".
Comment 7 Boris Zbarsky 2011-04-05 05:23:04 UTC
Right; using the parsed integer value is what the gecko pseudo-class does, in fact.
Comment 8 Leif Halvard Silli 2011-04-16 01:19:56 UTC
Tab: [1]

]]
> Until you provide details to the opposite, it seems most logical to
> assume that you are under the same misunderstanding that Aryeh and
> James once where.

Indeed, there is an inconsistency in the current Rendering section, as
it applies the rule about mapping @border values to 'border-width'
lengths only to the <table>, not the contained cells.
[[

[1] http://lists.w3.org/Archives/Public/www-archive/2011Apr/0079
Comment 9 jidanni 2011-04-22 03:16:07 UTC
I'm the https://bugzilla.wikimedia.org/show_bug.cgi?id=18829 guy.
There should be both border="0" and border="1" allowed.
Just like HTML4.
Otherwise you all are off your rocker.
To put it lightly.
That's what you get for ripping up standards.
Comment 10 Ian 'Hixie' Hickson 2011-06-15 06:44:58 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Concurred with reporter's comments.

For the record, here is all that you had to say in this bug (thanks Tab and bz):

"data:text/html,<!doctype html>
<table border=15><td>A<td>B</table>
<table border=0><td>A<td>B</table>

The spec says that the first table should have a 15px border and the second no border, which is correct.  But it says that both of them should have 1px borders on each cell, which is wrong for the latter table. Furthermore, for example, border=" 0 " needs to be treated just like border="0"."
Comment 11 contributor 2011-06-15 06:46:10 UTC
Checked in as WHATWG revision r6234.
Check-in comment: <table border=0> effect on <td> and <th>
http://html5.org/tools/web-apps-tracker?from=6233&to=6234
Comment 12 Yuhong Bao 2011-07-06 07:40:58 UTC
AFAIK, HTML 3.0 treated the border attribute as a boolean attribute.
Comment 13 Michael[tm] Smith 2011-08-04 05:03:04 UTC
mass-moved component to LC1
Comment 14 Leif Halvard Silli 2011-08-10 19:52:43 UTC
Thanks.