8000 csswg-drafts/css3-tables/Overview.html at cf2426f5819e48367abea146dd5d1d10ab8dc4fe · w3c/csswg-drafts · GitHub
Skip to content
7FFF

Latest commit

 

History

History
3960 lines (3028 loc) · 141 KB

File metadata and controls

3960 lines (3028 loc) · 141 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang=en>
<head profile="http://dublincore.org/documents/2008/08/04/dc-html/ ">
<meta charset=utf8>
<title>CSS3 Tables Module</title>
<link href="http://purl.org/dc/terms/" rel=schema.dcterms>
<link href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=dcterms.rights>
<meta content="CSS3 Tables Module" name=dcterms.title>
<meta content=text name=dcterms.type>
<meta content=2014-02-03 name=dcterms.date>
<meta content="Bert Bos" name=dcterms.creator>
<meta content="[editor name" name=dcterms.creator>
<meta content=W3C name=dcterms.publisher>
<meta content="http://dev.w3.org/csswg/css3-tables/"
name=dcterms.identifier>
<link href="../default.css" rel=stylesheet type="text/css">
<style type="text/css">
/* Just in case an incorrect max-width occurs in default.css */
body {max-width: none !important}
</style>
<link href="http://www.w3.org/StyleSheets/TR/W3C-ED" rel=stylesheet
type="text/css">
<body>
<div class=head> <!--begin-logo-->
<p><a href="http://www.w3.org/"><img alt=W3C height=48
src="http://www.w3.org/Icons/w3c_home" width=72></a> <!--end-logo-->
<h1>CSS3 Tables Module</h1>
<h2 class="no-num no-toc">Editor's Draft 3 February 2014</h2>
<dl>
<dt>This version:
<dd><a
href="http://dev.w3.org/csswg/css3-tables/">http://www.w3.org/2014/MO-css3-tables-20140203</a>
<dt>Latest version:
<dd><a
href="http://www.w3.org/TR/css3-tables/">http://www.w3.org/TR/css3-tables/</a>
<dt>Previous version:
<dd><a
href="[http://www.w3.org/PreviousVersionURI]">[http://www.w3.org/PreviousVersionURI]</a>
<dt>Feedback:
<dd><a
href="mailto:www-style@w3.org?subject=%5Bcss-tables%5D%20feedback">www-style@w3.org</a>
with subject line “<kbd>[css-tables] <var>… message topic
…</var></kbd>” (<a
href="http://lists.w3.org/Archives/Public/www-style/"
rel=discussion>archives</a>)
<dt>Editors:
<dd><a href="http://www.w3.org/People/Bos">Bert Bos</a>, <a
href="http://www.w3.org/">W3C</a>, <a
href="mailto:bert@w3.org">&lt;bert@w3.org&gt;</a>
<dd>[editor name, affiliation (opt.), email address (opt.)]
</dl>
<!--begin-copyright-->
<p class=copyright><a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
rel=license>Copyright</a> © 2014 <a href="http://www.w3.org/"><abbr
title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> (<a
href="http://www.csail.mit.edu/"><abbr
title="Massachusetts Institute of Technology">MIT</abbr></a>, <a
href="http://www.ercim.eu/"><abbr
title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
<a href="http://www.keio.ac.jp/">Keio</a>, <a
href="http://ev.buaa.edu.cn/">Beihang</a>), All Rights Reserved. W3C <a
href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
<a
href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>
and <a
href="http://www.w3.org/Consortium/Legal/copyright-documents">document
use</a> rules apply.</p>
<!--end-copyright-->
<hr title="Separator for header">
</div>
<h2 class="no-num no-toc" id=abstract>Abstract</h2>
<p>CSS (Cascading Style Sheets) is a language for specifying the rendering
of a structured document (in HTML or XML). See the CSS3 introduction <a
href="#ref-CSS3INTRO" rel=biblioentry>[CSS3INTRO]<!--{{CSS3INTRO}}--></a>
for more on CSS. The <em>CSS3 table module</em> is one of the modules of
level 3 of CSS and defines the properties that specify how tables are to
be displayed visually or spoken by a speech synthesizer.
<p>This is a very rough draft. It consists of the text of the CSS2 chapter
on tables, with almost no changes yet., except for the addition of the
first section, "Tabs &amp; leaders."
<h2 class="no-num no-toc" id=status>Status of this document</h2>
<details class=annoying-warning open=open> <summary>This document is
obsolete.</summary> This specification is not being actively maintained,
and should not be used as a guide for implementations. It may be revived in
the future, but for now should be considered obsolete. <br>
If you have questions or comments on this specification, please send an
email to the CSS Working Group's mailing list at <a
href="mailto:www-style@w3.org">www-style@w3.org</a>. (Before sending mail
for the first time, you have to subscribe at <a
href="http://lists.w3.org/Archives/Public/www-style/">http://lists.w3.org/Archives/Public/www-style/</a>.)
</details><!--begin-status-->
<p>This is a public copy of the editors' draft. It is provided for
discussion only and may change at any moment. Its publication here does
not imply endorsement of its contents by W3C. Don't cite this document
other than as work in progress.
<p>The (<a
href="http://lists.w3.org/Archives/Public/www-style/">archived</a>) public
mailing list <a
href="mailto:www-style@w3.org?Subject=%5Bcss3-tables%5D%20PUT%20SUBJECT%20HERE">
www-style@w3.org</a> (see <a
href="http://www.w3.org/Mail/Request">instructions</a>) is preferred for
discussion of this specification. When sending e-mail, please put the text
“css3-tables” in the subject, preferably like this:
“[<!---->css3-tables<!---->] <em>…summary of comment…</em>”
<p>This document was produced by the <a
href="http://www.w3.org/Style/CSS/members">CSS Working Group</a> (part of
the <a href="http://www.w3.org/Style/">Style Activity</a>).
<p>This document was produced by a group operating under the <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</a>. W3C maintains a <a
href="http://www.w3.org/2004/01/pp-impl/32061/status"
rel=disclosure>public list of any patent disclosures</a> made in
connection with the deliverables of the group; that page also includes
instructions for disclosing a patent. An individual who has actual
knowledge of a patent which the individual believes contains <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential
Claim(s)</a> must disclose the information in accordance with <a
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</a>.</p>
<!--end-status-->
<p>The text hasn't yet been synchronized with the latest version of
CSS 2.1.
<h2 class="no-num no-toc"><a name=contents>Table of contents</a></h2>
<!--begin-toc-->
<ul class=toc>
<li><a href="#dependencies-on-other-modules"><span class=secno>1.
</span>Dependencies on other modules</a>
<li><a href="#the-tab-properties-tabs-and-leaders"><span class=secno>2.
</span>The ‘<code class=property>tab</code>’ properties: tabs and
leaders</a>
<li><a href="#introduction-to-tables"><span class=secno>3.
</span>Introduction to tables</a>
<li><a href="#the-css-table-model"><span class=secno>4. </span>The CSS
table model</a>
<ul class=toc>
<li><a href="#anonymous-boxes"><span class=secno>4.1. </span>Anonymous
table objects</a>
</ul>
<li><a href="#columns"><span class=secno>5. </span>Columns</a>
<li><a href="#model"><span class=secno>6. </span>Tables in the visual
formatting model</a>
<ul class=toc>
<li><a href="#caption-position-and-alignment"><span class=secno>6.1.
</span>Caption position and alignment</a>
</ul>
<li><a href="#Visual"><span class=secno>7. </span>Visual layout of table
contents</a>
<ul class=toc>
<li><a href="#table-layers"><span class=secno>7.1. </span>Table layers
and transparency</a>
<li><a href="#width-layout"><span class=secno>7.2. </span>Table width
algorithms: the ‘<code class=property>table-layout</code>’
property</a>
<ul class=toc>
<li><a href="#fixed-table-layout"><span class=secno>7.2.1.
</span>Fixed table layout</a>
<li><a href="#auto-table-layout"><span class=secno>7.2.2.
</span>Automatic table layout</a>
</ul>
<li><a href="#height-layout"><span class=secno>7.3. </span>Table height
algorithms</a>
<li><a href="#column-alignment"><span class=secno>7.4. </span>Horizontal
alignment in a column</a>
<li><a href="#dynamic-effects"><span class=secno>7.5. </span>Dynamic row
and column effects</a>
</ul>
<li><a href="#borders"><span class=secno>8. </span>Borders</a>
<ul class=toc>
<li><a href="#separated-borders"><span class=secno>8.1. </span>The
separated borders model</a>
<ul class=toc>
<li><a href="#empty-cells"><span class=secno>8.1.1. </span>Borders
around empty cells: the ‘<code class=property>empty-cells</code>’
property</a>
</ul>
<li><a href="#collapsing-borders"><span class=secno>8.2. </span>The
collapsing border model</a>
<ul class=toc>
<li><a href="#border-conflict-resolution"><span class=secno>8.2.1.
</span>Border conflict resolution</a>
<li><a href="#collapsed-bg"><span class=secno>8.2.2.
</span>Backgrounds in the collapsed border model</a>
</ul>
6D50
<li><a href="#border-styles"><span class=secno>8.3. </span>Border
styles</a>
</ul>
<li><a href="#the-table-column-span-and-table-row-span"><span
class=secno>9. </span>The ‘<code
class=property>table-column-span</code>’ and ‘<code
class=property>table-row-span</code>’ properties</a>
<li><a href="#aligning-tables-table-baseline-property"><span
class=secno>10. </span>Aligning tables: ‘<code
class=property>table-baseline</code>’ property</a>
<li><a href="#audio-rendering-of-tables"><span class=secno>11.
</span>Audio rendering of tables</a>
<ul class=toc>
<li><a href="#speak-headers"><span class=secno>11.1. </span>Speaking
headers: the ‘<code class=property>speak-header</code>’
property</a>
</ul>
<li class=no-num><a href="#acknowledgments">Acknowledgments</a>
<li class=no-num><a href="#references">References</a>
<ul class=toc>
<li class=no-num><a href="#normative-references">Normative
references</a>
<li class=no-num><a href="#other-references">Other references</a>
</ul>
<li class=no-num><a href="#index">Index</a>
<li class=no-num><a href="#property-index">Property index</a>
</ul>
<!--end-toc-->
<hr>
<h2 id=dependencies-on-other-modules><span class=secno>1.
</span>Dependencies on other modules</h2>
<p>This CSS3 module depends on the following other CSS3 modules:
<ul>
<li>CSS3 Box Model <a href="#ref-CSS3BOX"
rel=biblioentry>[CSS3BOX]<!--{{!CSS3BOX}}--></a>
<li>CSS3 Syntax Module <a href="#ref-CSS3SYN"
rel=biblioentry>[CSS3SYN]<!--{{!CSS3SYN}}--></a>
<li>CSS3 Values and Units Module <a href="#ref-CSS3VAL"
rel=biblioentry>[CSS3VAL]<!--{{!CSS3VAL}}--></a>
<li>[module]
</ul>
<h2 id=the-tab-properties-tabs-and-leaders><span class=secno>2. </span>The
‘<a href="#tab"><code class=property>tab</code></a>’ properties: tabs
and leaders</h2>
<p class=issue>[Does it belong here, or in the line box model?]
<p class=issue>[This material is new. (Well, actually, <a
href=css-tabs.html>it dates from 1996</a>, but it is new in this draft.)
Not reviewed yet in any way.]
<p class=issue>[The name "tab" maybe reminds people too much of the tab
character, which plays no role here at all. Maybe a different name is
better. "Anchor"?]
<p class=issue>[Could this be merged with the margin-left/margin-right
properties to save some properties? ‘<code class=css>margin-left: 25%
fixed</code>’ instead of ‘<code class=css>tab: 25% left</code>’?]
<p class=issue>Håkon will write a proposal for a ‘<code
class=css>leader(&lt;string&gt;)</code>’ notation that can be put in the
‘<code class=property>content</code>’ property, inside ‘<code
class=css>::after</code>’ and ‘<code class=css>::before</code>’,
independent of any tab properties. It will push everything after it (up to
the end of the block or the explicit next line break, whichever comes
first) forward, so that it ends at the end of a line. Often, that may make
tabs unnecessary. [12 Jan 2005] That proposal is now in <a
href="#ref-CSS3GCPM" rel=biblioentry>[CSS3GCPM]<!--{{CSS3GCPM}}--></a>.
<table class=propdef>
<tbody>
<tr>
<td><em>Name:</em>
<td><dfn id=tab-position>tab-position</dfn>
<tr>
<td><em>Value:</em>
<td><var>&lt;length&gt;</var> | <var>&lt;percentage&gt;</var>
<tr>
<td><em>Initial:</em>
<td>0
<tr>
<td><em>Applies to:</em>
<td>inline-level elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>width* of containing block
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed value:</em>
<td>&lt;length&gt;
<tr>
<td colspan=2>*) if the containing block is ‘<code
class=property>horizontal</code>’, otherwise height
</table>
<table class=propdef>
<tbody>
<tr>
<td><em>Name:</em>
<td><dfn id=tab-align>tab-align</dfn>
<tr>
<td><em>Value:</em>
<td>left | top | center | right | bottom | <var>&lt;string&gt;</var> |
none
<tr>
<td><em>Initial:</em>
<td>none
<tr>
<td><em>Applies to:</em>
<td>inline-level elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed value:</em>
<td>specified value
</table>
<table class=propdef>
<tbody>
<tr>
<td><em>Name:</em>
<td><dfn id=tab-leaders>tab-leaders</dfn>
<tr>
<td><em>Value:</em>
<td><var>&lt;string&gt;</var>
<tr>
<td><em>Initial:</em>
<td>"" (empty string)
<tr>
<td><em>Applies to:</em>
<td>inline-level elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed value:</em>
<td>specified value
</table>
<table class=propdef>
<tbody>
<tr>
<td><em>Name:</em>
<td><dfn id=tab-leaders-alignment>tab-leaders-alignment</dfn>
<tr>
<td><em>Value:</em>
<td>aligned | centered | distributed
<tr>
<td><em>Initial:</em>
<td>aligned
<tr>
<td><em>Applies to:</em>
<td>inline-level elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>N/A
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed value:</em>
<td>specified value
</table>
<table class=propdef>
<tbody>
<tr>
<td><em>Name:</em>
<td><dfn id=tab>tab</dfn>
<tr>
<td><em>Value:</em>
<td>[ &lt;‘<a href="#tab-position"><code
class=property>tab-position</code></a>’&gt; || &lt;‘<a
href="#tab-align"><code class=property>tab-align</code></a>’&gt; ] [
/ [ &lt;‘<a href="#tab-leaders"><code
class=property>tab-leaders</code></a>’&gt; || &lt;‘<a
href="#tab-leaders-alignment"><code
class=property>tab-leaders-alignment</code></a>’&gt; ] ]?
<tr>
<td><em>Initial:</em>
<td>see individual properties
<tr>
<td><em>Applies to:</em>
<td>inline-level elements
<tr>
<td><em>Inherited:</em>
<td>no
<tr>
<td><em>Percentages:</em>
<td>see individual properties
<tr>
<td><em>Media:</em>
<td>visual
<tr>
<td><em>Computed value:</em>
<td>see individual properties
</table>
<p>An inline element can be put at a specific position in the line by
setting the element's <a class=property href="#tab">‘<code
class=property>tab</code>’</a> property. The space that creates before
the element can be filled with <dfn id=leaders>leaders</dfn> or left
blank.
<div class=example>
<p>Here are some examples:
<pre>signature { tab: 100% right } /* right-aligned at end of line */
amount { tab: -1em "." } /* aligned on dot, 1em from end of line */
desc { tab: 0 left } /* left-aligned to start of line */
pageno { tab: 100% right / " . " } /* right-aligned, with dot leaders */
col2 { tab: 50% center / " · " } /* centered in the line */</pre>
<p>With a document fragment like the following:
<pre>&lt;expenses&gt;
&lt;desc&gt;Hotel&lt;/desc&gt; &lt;amount&gt;374.55&lt;/amount&gt;
&lt;desc&gt;Travel&lt;/desc&gt; &lt;amount&gt;1460.10&lt;/amount&gt;
&lt;desc&gt;Miscellaneous, including presents and
tips&lt;/desc&gt; &lt;amount&gt;84.00&lt;/amount&gt;
&lt;desc&gt;Total&lt;/desc&gt; &lt;amount&gt;1918.65&lt;/amount&gt;
&lt;signature&gt;Ph. Fogg&lt;/signature&gt;
&lt;/expenses&gt;</pre>
<p>The rendering might be as follows:
<div class=figure>
<p><img alt="[image]" src=tabs.png>
<p class=caption>Possible rendering of a text with tabs and leaders
</div>
</div>
<p>The <a class=property href="#tab-position">‘<code
class=property>tab-position</code>’</a> and <a class=property
href="#tab-align">‘<code class=property>tab-align</code>’</a>
determine the position of the element in the line. The element is
positioned by inserting extra whitespace or leaders before it. Setting a
tab will never cause the element to overlap any other element on the line
(unless it would already overlap without the tab, because of negative
margins). It may be necessary for the UA to insert so much
whitespace/leaders, that the alignment point of the tab occurs on one of
the following lines. (The example above shows one such case.)
<p>The <a class=property href="#tab-position">‘<code
class=property>tab-position</code>’</a> gives the position of a point on
the line to which the element will be aligned. A negative
<var>&lt;length&gt;</var> is measured from the end of the line, a
nonnegative one from the beginning. Ditto for percentages, where
percentages are relative to the width of the <span>containing block</span>
(or height, if the containing block's <span>orientation</span> is
vertical). It depends on the writing mode of the containing block which
edge is the start of the line. <span class=issue>[Or is it more intuitive
to always count positive lengths from the left or top and negative ones
from the right or bottom?]</span>
<p>The position is measured from the <em>content edge</em> of the
containing block and is independent of any floats that may make the line
box narrower than the content box. As usual for inline elements in the
presence of floats, the alignment point and the element to which it
belongs will be moved to a following line, if it would otherwise overlap
the float.
<p class=note>Note that a value of ‘<code class=css>0</code>’ means the
start of the line. Use 100% to refer to the end of the line.
<p><a class=property href="#tab-align">‘<code
class=property>Tab-align</code>’</a> specifies how the element is
aligned to the alignment point:
<dl>
<dt>‘<a href="#none"><code class=property>none</code></a>’
<dd>The element is not aligned to any alignment point and is put
immediately after the previous element, with no intervening leaders.
<dt>‘<code class=property>left</code>’, ‘<a href="#top0"><code
class=property>top</code></a>’
<dd>These are the same and mean that the left <em>margin edge</em> (or
top, if vertical) of the element is at the given position in the line.
<p>If the element consists of multiple boxes (because of bidi processing
or line breaks), which of the boxes is aligned depends on the <a
class=property href="#direction">‘<code
class=property>direction</code>’</a> of the containing block: the
first box in the case of <span class=css>‘<code
class=property>ltr</code>’</span>, the last box in the case of <span
class=css>‘<code class=property>rtl</code>’</span>.
<dt>‘<code class=property>right</code>’, ‘<a href="#bottom0"><code
class=property>bottom</code></a>’
<dd>The right <em>margin edge</em> (or bottom, if vertical) is at the
given position. If the <a class=property href="#direction">‘<code
class=property>direction</code>’</a> of the containing block is <span
class=css>‘<code class=property>ltr</code>’</span>, the element's
last box is aligned, otherwise the first box.
<dt>‘<code class=property>center</code>’
<dd>The element is centered around the given position. If a line break
occurs inside the element, the element might not be centered exactly.
<dt><var>&lt;string&gt;</var>
<dd>The beginning of the first occurrence of the string in the element is
put at the alignment point. If the string does not occur in the element,
the end of the content of the element is aligned.
</dl>
<p class=issue>[Do we need ‘<code class=property>start</code>’ and
‘<code class=property>end</code>’ keywords that dynamically resolve to
‘<code class=property>left</code>’ or ‘<code
class=property>right</code>’ depending on the writing direction?
Probably not very useful. Ltr and rtl are not symmetrical: even in rtl
text, numbers are right aligned.]
<p>The <a class=property href="#tab-leaders">‘<code
class=property>tab-leaders</code>’</a> property determines what is
inserted before the element to make it align. If the value is the empty
string, only whitespace is inserted, otherwise multiple copies of the
string are inserted, as many as needed. If there is not room for a whole
number of copies, the remaining part is filled with whitespace. The style
(color, font, etc.) of the leaders is that of the element's parent (i.e.,
not necessarily the same as the element's own style).
<p>The values of <a class=property href="#tab-leaders-alignment">‘<code
class=property>tab-leaders-alignment</code>’</a> have the following
meaning:
<dl>
<dt>‘<code class=property>centered</code>’
<dd>If the space for the leaders is not a whole number of copies of the <a
class=property href="#tab-leaders">‘<code
class=property>tab-leaders</code>’</a> string, half of the extra
whitespace is inserted before the first string, and half after the last
string. (If there is a line break the middle of the leaders, it may not
be possible to have exactly half the space on both sides.)
<dt>‘<code class=property>distributed</code>’
<dd>Like for <span class=css>‘<code
class=property>centered</code>’</span>, but the extra whitespace is
inserted in equal amounts before the first, after the last and between
the strings.
<dt>‘<code class=property>aligned</code>’
<dd>The <a class=property href="#tab-leaders">‘<code
class=property>tab-leaders</code>’</a> strings are positioned such that
there is room for exactly a whole number of copies between the string and
the left content edge of the containing block. <span class=note>Note that
this has the effect that all ‘<code class=property>aligned</code>’
leaders on different lines are aligned with each other, as if they were
attached to a common grid. The dot leaders in the previous example form
such a grid.</span>
</dl>
<p>The <a class=property href="#tab">‘<code
class=property>tab</code>’</a> property is a shorthand to set all four
properties together. Omitted values default to their initial values.
<p class=note>Note the slash (/) in the value of <a class=property
href="#tab">‘<code class=property>tab</code>’</a>: if leaders are
specified, they must be separated from the position &amp; alignment with a
slash.
<p class=note>Note that <span class=css>‘<code class=css>tab: 2em /
"."</code>’</span> is a valid, and occasionally useful declaration, but
by itself does not cause any leaders to appear, because it implicitly sets
<a class=property href="#tab-align">‘<code
class=property>tab-align</code>’</a> to <a class=css
href="#none">‘<code class=property>none</code>’</a>.
<p>Justification and line breaking algorithms may change the size of an
element, but leave it aligned at the alignment point. (Although different
algorithms and different settings of the relevant properties may cause the
alignment point to fall on different lines.)
<p class=issue>[Do we need keywords such as ‘<code class=css>arrow-leader
(for a stretchy arrow) or </code>’double-arrow-leader', or can they be
made from existing characters? Or should ‘<a href="#tab-leaders"><code
class=property>tab-leaders</code></a>’ accept up to 3 strings, e.g.,
"\2190" "\2500" "\2192" ("←" "─" "→"), for start, middle and end of
the leaders?]
<h2 id=introduction-to-tables><span class=secno>3. </span>Introduction to
tables</h2>
<p class=issue>What happens with tables in vertical text (‘<code
class=css>writing-mode: tb-rl</code>’ etc.)? Are tables rotated or not?
Currently, the specification says rows are horizontal and the only
influence is from ‘<a href="#direction"><code
class=property>direction</code></a>’, which may cause the next column to
be on the left of the current one instead of the right.
<p>Table mark-up in a source document typically represents a particular
relationship between three or more dimensions of data, e.g., dates,
products and the number of units sold. Table properties in CSS are meant
to style the representation of such data as a table. But the properties
can occasionally also be used to align elements in rows and columns for
purely visual reasons, rather than semantics. Unlike, e.g., the <a
href="#table"><code class=html>table</code></a> element in HTML, the <a
class=property href="#table">‘<code class=property& EDE6 gt;table</code>’</a>
keyword doesn't imply any particular semantic relation between elements in
the document.
<div class=example>
<p> Here is a simple three-row, three-column table described in HTML 4:
<pre class=html-example>
&lt;TABLE&gt;
&lt;CAPTION&gt;This is a simple 3x3 table&lt;/CAPTION&gt;
&lt;TR id="row1"&gt;
&lt;TH&gt;Header 1 &lt;TD&gt;Cell 1 &lt;TD&gt;Cell 2
&lt;TR id="row2"&gt;
&lt;TH&gt;Header 2 &lt;TD&gt;Cell 3 &lt;TD&gt;Cell 4
&lt;TR id="row3"&gt;
&lt;TH&gt;Header 3 &lt;TD&gt;Cell 5 &lt;TD&gt;Cell 6
&lt;/TABLE&gt;
</pre>
<p>This code creates one table (the <a href="#table"><code
class=html>TABLE</code></a> element), three rows (the <code
class=html>TR</code> elements), three header cells (the <code
class=html>TH</code> elements), and six data cells (the <code
class=html>TD</code> elements). Note that the three columns of this
example are specified implicitly: there are as many columns in the table
as required by header and data cells.
<p>The following CSS rule centers the text horizontally in the header
cells and presents the text in the header cells with a bold font weight:
<pre>
th { text-align: center; font-weight: bold }
</pre>
<p>The next rules align the text of the header cells on their baseline and
vertically center the text in each data cell:
<pre>
th { vertical-align: baseline }
td { vertical-align: middle }
</pre>
<p>The next rules specify that the top row will be surrounded by a 3px
solid blue border and each of the other rows will be surrounded by a 1px
solid black border:
<pre>
table { border-collapse: collapse }
tr#row1 { border: 3px solid blue }
tr#row2 { border: 1px solid black }
tr#row3 { border: 1px solid black }
</pre>
<p>Note, however, that the borders around the rows overlap where the rows
meet. What color (black or blue) and thickness (1px or 3px) will the
border between row1 and row2 be? We discuss this in the section on <a
href="#border-conflict-resolution">border conflict resolution.</a>
<p>The following rule puts the table caption above the table:
<pre>
caption { caption-side: top }
</pre>
</div>
<p>The preceding example shows how CSS works with HTML 4 elements; in HTML
4, the semantics of the various table elements (TABLE, CAPTION, THEAD,
TBODY, TFOOT, COL, COLGROUP, TH, and TD) are well-defined. In other
document languages (such as XML applications), there may not be
pre-defined table elements. Therefore, CSS 2.1 allows authors to <span
class=index-inst id=map
title="mapping elements to table parts">"map"</span> document language
elements to table elements via the <a class=propinst-display
href="#display">‘<code class=property>display</code>’</a> property.
For example, the following rule makes the FOO element act like an HTML
TABLE element and the BAR element act like a CAPTION element:
<pre class=example>
FOO { display : table }
BAR { display : table-caption }
</pre>
<p id=internal>We discuss the various table elements in the following
section. In this specification, the term <a class=index-def
href="#table-element" id=table-element0 title="table element"><dfn
id=table-element>table element</dfn></a> refers to any element involved in
the creation of a table. An <span class=index-def
id="âinternalâ-table-element"
title="internal table element|table element::internal">“internal”
table element</span> is one that produces a row, row group, column, column
group, or cell.
<h2 id=the-css-table-model><span class=secno>4. </span>The CSS table model</h2>
<p>The CSS table model is based on the HTML 4.0 table model, in which the
structure of a table closely parallels the visual layout of the table. In
this model, a table consists of an optional caption and any number of rows
of cells. The table model is said to be “row primary,” since authors
specify rows, not columns, explicitly in the document language. Columns
are derived once all the rows have been specified: the first cell of each
row belongs to the first column, the second to the second column, etc.).
Rows and columns may be grouped structurally and this grouping reflected
in presentation (e.g., a border may be drawn around a group of rows).
<p>Thus, the table model consists of tables, captions, rows, row groups,
columns, column groups, and cells.
<p>The CSS model does not require that the <span>document language</span>
include elements that correspond to each of these components. For document
languages (such as XML applications) that do not have pre-defined table
elements, authors must map document language elements to table elements;
this is done with the ‘<a href="#display"><code
class=property>display</code></a>’ property. The following ‘<a
href="#display"><code class=property>display</code></a>’ values assign
table formatting rules to an arbitrary element:
<dl>
<dt><dfn id=table>table</dfn> (In HTML: TABLE)
<dd>Specifies that an element defines a <em>block-level</em> table: it is
a rectangular block that participates in a <em>block formatting
context</em>.
<dt><dfn id=inline-table>inline-table</dfn> (In HTML: TABLE)
<dd>Specifies that an element defines an <em>inline-level</em> table: it
is a rectangular block that participates in an <em>inline formatting
context</em>.
<dt><dfn id=table-row>table-row</dfn> (In HTML: TR)
<dd>Specifies that an element is a row of cells.
<dt><dfn id=table-row-group>table-row-group</dfn> (In HTML: TBODY)
<dd>Specifies that an element groups one or more rows.
<dt><dfn id=table-header-group0>table-header-group</dfn> (In HTML: THEAD)
<dd>Like ‘<a href="#table-row-group"><code
class=property>table-row-group</code></a>’, but for visual formatting,
the row group is always displayed before all other rows and row groups
and after any top captions. Print user agents may repeat header rows on
each page spanned by a table. If a table contains multiple elements with
‘<code class=css>display: table-header-group</code>’, only the first
is rendered as a header; the others are treated as if they had ‘<code
class=css>display: table-row-group</code>’.
<dt><dfn id=table-footer-group>table-footer-group</dfn> (In HTML: TFOOT)
<dd>Like ‘<a href="#table-row-group"><code
class=property>table-row-group</code></a>’, but for visual formatting,
the row group is always displayed after all other rows and row groups and
before any bottom captions. Print user agents may repeat footer rows on
each page spanned by a table. If a table contains multiple elements with
‘<code class=css>display: table-footer-group</code>’, only the first
is rendered as a footer; the others are treated as if they had ‘<code
class=css>display: table-row-group</code>’.
<dt><dfn id=table-column>table-column</dfn> (In HTML: COL)
<dd>Specifies that an element describes a column of cells.
<dt><dfn id=table-column-group>table-column-group</dfn> (In HTML:
COLGROUP)
<dd>Specifies that an element groups one or more columns.
<dt><dfn id=table-cell>table-cell</dfn> (In HTML: TD, TH)
<dd>Specifies that an element represents a table cell.
<dt><dfn id=table-caption>table-caption</dfn> (In HTML: CAPTION)
<dd>Specifies a caption for the table. All elements with ‘<code
class=css>display: table-caption</code>’ must be rendered, as described
in <a href="#model">section [??].</a>
</dl>
<p>Replaced elements with these ‘<a href="#display"><code
class=property>display</code></a>’ values are treated as their given
display types during layout. For example, an image that is set to ‘<code
class=css>display: table-cell</code>’ will fill the available cell
space, and its dimensions might contribute towards the table sizing
algorithms, as with an ordinary cell.
<p>Elements with ‘<a href="#display"><code
class=property>display</code></a>’ set to ‘<a
href="#table-column"><code class=property>table-column</code></a>’ or
‘<a href="#table-column-group"><code
class=property>table-column-group</code></a>’ are not rendered (exactly
as if they had ‘<code class=css>display: none</code>’), but they are
useful, because they may have attributes which induce a certain style for
the columns they represent.
<div class=issue>
<p>The above, rewritten for ‘<code
class=property>display-model</code>’ and ‘<code
class=property>display-role</code>’:
<p>The values of <span class=property>‘<code
class=property>display-model</code>’</span> that apply to tables have
the following meaning. (For the purposes of the definitions in this
section, any child elements with a <span class=property>‘<code
class=property>display-role</code>’</span> of <a class=css
href="#none">‘<code class=property>none</code>’</a> are considered to
have been removed from the document tree.)
<dl>
<dt>table
<dd>
<p>The child elements are laid out as a stack of row-groups. In detail:
<p>Any uninterrupted sequence of child elements, including anonymous
ones, with a role other than <span class=css>‘<code
class=css>table-{row,header,footer}-group</code>’</span> or <a
class=css href="#table-caption">‘<code
class=property>table-caption</code>’</a> is wrapped in an anonymous
element with role and model both set to <a class=css
href="#table-row-group">‘<code
class=property>table-row-group</code>’</a>.
<p>The resulting set of children is laid out as a stack of rows from top
to bottom, with at the top any <a class=css
href="#table-header-group0">‘<code
class=property>table-header-group</code>’</a> child, then the <a
class=css href="#table-row-group">‘<code
class=property>table-row-group</code>’</a> children, in the order of
the document, and finally any <a class=css
href="#table-footer-group">‘<code
class=property>table-footer-group</code>’</a> child. (Note also the
difference between these three types for paged media, described <a
href="#table-header-group">below.</a>)
<dt>table-row-group
<dd>
<p>The children are laid out as a stack of rows. In detail:
<p>Any uninterrupted sequence of child elements with a role other than
<a class=css href="#table-row">‘<code
class=property>table-row</code>’</a> is wrapped in an anonymous
element with role set to <a class=css href="#table-row">‘<code
class=property>table-row</code>’</a> and model set to <span
class=css>‘<code class=property>block-inside</code>’</span>.
<p>The resulting children are laid out as a stack of rows from top to
bottom in the order of the document.
<dt>table-row
<dd>
<p>The children are laid out as a row of table cells. In detail:
<p>Any uninterrupted sequence of children with a role other than <a