]> pere.pagekite.me Git - homepage.git/blob - reports/rfc/rfc1942.txt
Generated.
[homepage.git] / reports / rfc / rfc1942.txt
1
2
3
4
5
6
7 Network Working Group D. Raggett
8 Request for Comments: 1942 W3C
9 Category: Experimental May 1996
10
11
12 HTML Tables
13
14 Status of this Memo
15
16 This memo defines an Experimental Protocol for the Internet
17 community. This memo does not specify an Internet standard of any
18 kind. Discussion and suggestions for improvement are requested.
19 Distribution of this memo is unlimited.
20
21 Abstract
22
23 The HyperText Markup Language (HTML) is a simple markup language used
24 to create hypertext documents that are portable from one platform to
25 another. HTML documents are SGML documents with generic semantics
26 that are appropriate for representing information from a wide range
27 of applications. This specification extends HTML to support a wide
28 variety of tables. The model is designed to work well with associated
29 style sheets, but does not require them. It also supports rendering
30 to braille, or speech, and exchange of tabular data with databases
31 and spreadsheets. The HTML table model embodies certain aspects of
32 the CALS table model, e.g. the ability to group table rows into
33 thead, tbody and tfoot sections, plus the ability to specify cell
34 alignment compactly for sets of cells according to the context.
35
36 Table of Contents
37
38 Recent Changes ................................................. 1
39 Brief Introduction ............................................. 2
40 Design Rationale ............................................... 5
41 Walkthrough of the Table DTD ................................... 8
42 Recommended Layout Algorithms ................................. 23
43 HTML Table DTD ................................................ 26
44 References .................................................... 29
45 Security Considerations ....................................... 30
46 Author's Address .............................................. 30
47
48 Recent Changes
49
50 This specification extends HTML to support tables. The table model
51 has grown out of early work on HTML+ and the initial draft of HTML3.
52 The earlier model has been been extended in response to requests from
53 information providers for improved control over the presentation of
54 tabular information:
55
56
57
58 Raggett Experimental [Page 1]
59 \f
60 RFC 1942 HTML Tables May 1996
61
62
63 * alignment on designated characters such as "." and ":"
64 e.g. aligning a column of numbers on the decimal point
65
66 * more flexibility in specifying table frames and rules
67
68 * incremental display for large tables as data is received
69
70 * the ability to support scrollable tables with fixed headers plus
71 better support for breaking tables across pages for printing
72
73 * optional column based defaults for alignment properties
74
75 In addition, a major goal has been to provide backwards compatibility
76 with the widely deployed Netscape implementation of tables. A
77 subsidiary goal has been to simplify importing tables conforming to
78 the SGML CALS model. The latest draft makes the ALIGN attribute
79 compatible with the latest Netscape and Microsoft browsers. Some
80 clarifications have been made to the role of the DIR attribute and
81 recommended behaviour when absolute and relative column widths are
82 mixed.
83
84 A new element COLGROUP has been introduced to allow sets of columns
85 be grouped with different width and alignment properties specified by
86 one or more COL elements. The semantics of COLGROUP have been
87 clarified over previous drafts, and RULES=BASIC replaced by
88 RULES=GROUPS.
89
90 The FRAME and RULES attributes have been modified to avoid SGML name
91 clashes with each other, and to avoid clashes with the ALIGN and
92 VALIGN attributes. These changes were additionally motivated by the
93 desire to avoid future problems if this specification is extended to
94 allow FRAME and RULES attributes with other table elements.
95
96 A Brief Introduction to HTML Tables
97
98 Tables start with an optional caption followed by one or more rows.
99 Each row is formed by one or more cells, which are differentiated
100 into header and data cells. Cells can be merged across rows and
101 columns, and include attributes assisting rendering to speech and
102 braille, or for exporting table data into databases. The model
103 provides limited support for control over appearence, for example
104 horizontal and vertical alignment of cell contents, border styles and
105 cell margins. You can further affect this by grouping rows and
106 columns together. Tables can contain a wide range of content, such as
107 headers, lists, paragraphs, forms, figures, preformatted text and
108 even nested tables.
109
110
111
112
113
114 Raggett Experimental [Page 2]
115 \f
116 RFC 1942 HTML Tables May 1996
117
118
119 Example
120
121 <TABLE BORDER>
122 <CAPTION>A test table with merged cells</CAPTION>
123 <TR><TH ROWSPAN=2><TH COLSPAN=2>Average
124 <TH ROWSPAN=2>other<BR>category<TH>Misc
125 <TR><TH>height<TH>weight
126 <TR><TH ALIGN=LEFT>males<TD>1.9<TD>0.003
127 <TR><TH ALIGN=LEFT ROWSPAN=2>females<TD>1.7<TD>0.002
128 </TABLE>
129
130 On a dumb terminal, this would be rendered something like:
131
132 A test table with merged cells
133 /--------------------------------------------------\
134 | | Average | other | Misc |
135 | |-------------------| category |--------|
136 | | height | weight | | |
137 |-----------------------------------------|--------|
138 | males | 1.9 | 0.003 | | |
139 |-----------------------------------------|--------|
140 | females | 1.7 | 0.002 | | |
141 \--------------------------------------------------/
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170 Raggett Experimental [Page 3]
171 \f
172 RFC 1942 HTML Tables May 1996
173
174
175 Next, a richer example with grouped rows and columns (adapted from
176 "Developing International Software" by Nadine Kano). First here is
177 what the table looks like on paper:
178
179 CODE-PAGE SUPPORT IN MICROSOFT WINDOWS
180 ========================================================================
181 Code-Page| Name |ACP OEMCP| Windows Windows Windows
182 ID | | | NT 3.1 NT 3.51 95
183 ------------------------------------------------------------------------
184 1200 |Unicode (BMP of ISO 10646) | | X X *
185 1250 |Windows 3.1 East. Europe | X | X X X
186 1251 |Windows 3.1 Cyrillic | X | X X X
187 1252 |Windows 3.1 US (ANSI) | X | X X X
188 1253 |Windows 3.1 Greek | X | X X X
189 1254 |Windows 3.1 Turkish | X | X X X
190 1255 |Hebrew | X | X
191 1256 |Arabic | X | X
192 1257 |Baltic | X | X
193 1361 |Korean (Johab) | X | ** X
194 ------------------------------------------------------------------------
195 437 |MS-DOS United States | X | X X X
196 708 |Arabic (ASMO 708) | X | X
197 709 |Arabic (ASMO 449+, BCON V4)| X | X
198 710 |Arabic (Transparent Arabic)| X | X
199 720 |Arabic (Transparent ASMO) | X | X
200 ========================================================================
201
202 The markup for this uses COLGROUP elements to group columns and to
203 set default column alignment. TBODY elements are used to group rows.
204 The FRAME and RULES attributes are used to select which borders to
205 render.
206
207 <table border=2 frame=hsides rules=groups>
208 <caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption>
209 <colgroup align=center>
210 <colgroup align=left>
211 <colgroup align=center span=2>
212 <colgroup align=center span=3>
213 <thead valign=top>
214 <tr>
215 <th>Code-Page<br>ID
216 <th>Name
217 <th>ACP
218 <th>OEMCP
219 <th>Windows<br>NT 3.1
220 <th>Windows<br>NT 3.51
221 <th>Windows<br>95
222 <tbody>
223
224
225
226 Raggett Experimental [Page 4]
227 \f
228 RFC 1942 HTML Tables May 1996
229
230
231 <tr><td>1200<td>Unicode (BMP of ISO 10646)<td><td><td>X<td>X<TD>*
232 <tr><td>1250<td>Windows 3.1 Eastern European<td>X<td><td>X<td>X<TD>X
233 <tr><td>1251<td>Windows 3.1 Cyrillic<td>X<td><td>X<td>X<TD>X
234 <tr><td>1252<td>Windows 3.1 US (ANSI)<td>X<td><td>X<td>X<TD>X
235 <tr><td>1253<td>Windows 3.1 Greek<td>X<td><td>X<td>X<TD>X
236 <tr><td>1254<td>Windows 3.1 Turkish<td>X<td><td>X<td>X<TD>X
237 <tr><td>1255<td>Hebrew<td>X<td><td><td><td>X
238 <tr><td>1256<td>Arabic<td>X<td><td><td><td>X
239 <tr><td>1257<td>Baltic<td>X<td><td><td><td>X
240 <tr><td>1361<td>Korean (Johab)<td>X<td><td><td>**<td>X
241 <tbody>
242 <tr><td>437<td>MS-DOS United States<td><td>X<td>X<td>X<TD>X
243 <tr><td>708<td>Arabic (ASMO 708)<td><td>X<td><td><td>X
244 <tr><td>709<td>Arabic (ASMO 449+, BCON V4)<td><td>X<td><td><td>X
245 <tr><td>710<td>Arabic (Transparent Arabic)<td><td>X<td><td><td>X
246 <tr><td>720<td>Arabic (Transparent ASMO)<td><td>X<td><td><td>X
247 </table>
248
249 Design Rationale
250
251 The HTML table model has evolved from studies of existing SGML tables
252 models, the treatment of tables in common word processing packages,
253 and looking at a wide range of tabular layout in magazines, books and
254 other paper-based documents. The model was chosen to allow simple
255 tables to be expressed simply with extra complexity only when needed.
256 This makes it practical to create the markup for HTML tables with
257 everyday text editors and reduces the learning curve for getting
258 started. This feature has been very important to the success of HTML
259 to date.
260
261 Increasingly people are using filters from other document formats or
262 direct wysiwyg editors for HTML. It is important that the HTML table
263 model fits well with these routes for authoring HTML. This affects
264 how the representation handles cells which span multiple rows or
265 columns, and how alignment and other presentation properties are
266 associated with groups of cells.
267
268 A major consideration for the HTML table model is that the fonts and
269 window sizes etc. in use with browsers are not under the author's
270 control. This makes it risky to rely on column widths specified in
271 terms of absolute units such as picas or pixels. Instead, tables can
272 be dynamically sized to match the current window size and fonts.
273 Authors can provide guidance as to the relative widths of columns,
274 but user agents should to ensure that columns are wide enough to
275 render the width of the largest single element of the cell's content.
276 If the author's specification must be overridden, it is preferred
277 that the relative widths of individual columns are not changed
278 drastically.
279
280
281
282 Raggett Experimental [Page 5]
283 \f
284 RFC 1942 HTML Tables May 1996
285
286
287 For large tables or slow network connections, it is desirable to be
288 able to start displaying the table before all of the data has been
289 received. The default window width for most user agents shows about
290 80 characters, and the graphics for many HTML pages are designed with
291 these defaults in mind. Authors can provide a hint to user agents to
292 activate incremental display of table contents. This feature requires
293 the author to specify the number of columns, and includes provision
294 for control of table width and the widths of different columns in
295 relative or absolute terms.
296
297 For incremental display, the browser needs the number of columns and
298 their widths. The default width of the table is the current window
299 size (width="100%"). This can be altered by including a WIDTH
300 attribute in the TABLE start tag. By default all columns have the
301 same width, but you can specify column widths with one or more COL
302 elements before the table data starts.
303
304 The remaining issue is the number of columns. Some people have
305 suggested waiting until the first row of the table has been received,
306 but this could take a long time if the cells have a lot of content.
307 On the whole it makes more sense, when incremental display is
308 desired, to get authors to explicitly specify the number of columns
309 in the TABLE start tag.
310
311 Authors still need a way of informing the browser whether to use
312 incremental display or to automatically size the table to match the
313 cell contents. For the two pass auto sizing mode, the number of
314 columns is determined by the first pass, while for the incremental
315 mode, the number of columns needs to be stated up front. So it seems
316 to that COLS=_nn_ would be better for this purpose than a LAYOUT
317 attribute such as LAYOUT=FIXED or LAYOUT=AUTO.
318
319 It is generally held useful to consider documents from two
320 perspectives: Structural idioms such as headers, paragraphs, lists,
321 tables, and figures; and rendering idioms such as margins, leading,
322 font names and sizes. The wisdom of past experience encourages us to
323 separate the structural information in documents from rendering
324 information. Mixing them together ends up causing increased cost of
325 ownership for maintaining documents, and reduced portability between
326 applications and media.
327
328 For tables, the alignment of text within table cells, and the borders
329 between cells are, from the purist's point of view, rendering
330 information. In practice, though, it is useful to group these with
331 the structural information, as these features are highly portable
332 from one application to the next. The HTML table model leaves most
333 rendering information to associated style sheets. The model is
334 designed to take advantage of such style sheets but not to require
335
336
337
338 Raggett Experimental [Page 6]
339 \f
340 RFC 1942 HTML Tables May 1996
341
342
343 them.
344
345 This specification provides a superset of the simpler model presented
346 in earlier work on HTML+. Tables are considered as being formed from
347 an optional caption together with a sequence of rows, which in turn
348 consist of a sequence of table cells. The model further
349 differentiates header and data cells, and allows cells to span
350 multiple rows and columns.
351
352 Following the CALS table model, this specification allows table rows
353 to be grouped into head and body and foot sections. This simplifies
354 the representation of rendering information and can be used to repeat
355 table head and foot rows when breaking tables across page boundaries,
356 or to provide fixed headers above a scrollable body panel. In the
357 markup, the foot section is placed before the body sections. This is
358 an optimization shared with CALS for dealing with very long tables.
359 It allows the foot to be rendered without having to wait for the
360 entire table to be processed.
361
362 For the visually impaired, HTML offers the hope of setting to rights
363 the damage caused by the adoption of windows based graphical user
364 interfaces. The HTML table model includes attributes for labeling
365 each cell, to support high quality text to speech conversion. The
366 same attributes can also be used to support automated import and
367 export of table data to databases or spreadsheets.
368
369 Current desktop publishing packages provide very rich control over
370 the rendering of tables, and it would be impractical to reproduce
371 this in HTML, without making HTML into a bulky rich text format like
372 RTF or MIF. This specification does, however, offer authors the
373 ability to choose from a set of commonly used classes of border
374 styles. The FRAME attribute controls the appearence of the border
375 frame around the table while the RULES attribute determines the
376 choice of rulings within the table.
377
378 During the development of this specification, a number of avenues
379 were investigated for specifying the ruling patterns for tables. One
380 issue concerns the kinds of statements that can be made. Including
381 support for edge subtraction as well as edge addition leads to
382 relatively complex algorithms. For instance work on allowing the full
383 set of table elements to include the FRAME and RULES attributes led
384 to an algorithm involving some 24 steps to determine whether a
385 particular edge of a cell should be ruled or not. Even this
386 additional complexity doesn't provide enough rendering control to
387 meet the full range of needs for tables. The current specification
388 deliberately sticks to a simple intuitive model, sufficient for most
389 purposes. Further experimental work is needed before a more complex
390 approach is standardized.
391
392
393
394 Raggett Experimental [Page 7]
395 \f
396 RFC 1942 HTML Tables May 1996
397
398
399 A walk through the table DTD
400
401 The table document type definition provides the formal definition of
402 the allowed syntax for html tables. The following is an annotated
403 listing of the DTD. The complete listing appears at the end of this
404 document.
405
406 Note that the TABLE element is a block-like element rather a
407 character-level element. As such it is a peer of other HTML block-
408 like elements such as paragraphs, lists and headers.
409
410 Common Attributes
411
412 The following attributes occur in several of the elements and are
413 defined here for brevity. In general, all attribute names and values
414 in this specification are case insensitive, except where noted
415 otherwise. The ID, CLASS and attributes are required for use with
416 style sheets, while LANG and DIR are needed for internationalization.
417
418 <!ENTITY % attrs
419 "id ID #IMPLIED -- element identifier --
420 class NAMES #IMPLIED -- for subclassing elements --
421 lang NAME #IMPLIED -- as per RFC 1766 --
422 dir (ltr|rtl) #IMPLIED -- I18N text direction --">
423
424 ID
425 Used to define a document-wide identifier. This can be used for
426 naming positions within documents as the destination of a
427 hypertext link. It may also be used by style sheets for
428 rendering an element in a unique style. An ID attribute value is
429 an SGML NAME token. NAME tokens are formed by an initial letter
430 followed by letters, digits, "-" and "." characters. The letters
431 are restricted to A-Z and a-z.
432
433 CLASS
434 A space separated list of SGML NAME tokens. CLASS names specify
435 that the element belongs to the corresponding named classes. It
436 allows authors to distinguish different roles played by the same
437 tag. The classes may be used by style sheets to provide
438 different renderings as appropriate to these roles.
439
440 LANG
441 A LANG attribute identifies the natural language used by the
442 content of the associated element.The syntax and registry of
443 language values are defined by RFC 1766. In summary the language
444 is given as a primary tag followed by zero or more subtags,
445 separated by "-". White space is not allowed and all tags are
446 case insensitive. The name space of tags is administered by
447
448
449
450 Raggett Experimental [Page 8]
451 \f
452 RFC 1942 HTML Tables May 1996
453
454
455 IANA. The two letter primary tag is an ISO 639 language
456 abbreviation, while the initial subtag is a two letter ISO 3166
457 country code. Example values for LANG include:
458
459 en, en-US, en-uk, i-cherokee, x-pig-latin.
460
461 DIR
462 Human writing systems are grouped into scripts, which determine
463 amongst other things, the direction the characters are written.
464 Elements of the Latin script are nominally left to right, while
465 those of the Arabic script are nominally right to left. These
466 characters have what is called strong directionality. Other
467 characters can be directionally neutral (spaces) or weak
468 (punctuation).
469
470 The DIR attribute specifies an encapsulation boundary which
471 governs the interpretation of neutral and weakly directional
472 characters. It does not override the directionality of strongly
473 directional characters. The DIR attribute value is one of LTR
474 for left to right, or RTL for right to left, e.g. DIR=RTL.
475
476 When applied to TABLE, it indicates the geometric layout of rows
477 (i.e. row 1 is on right if DIR=RTL, but on the left if DIR=LTR)
478 and it indicates a default base directionality for any text in
479 the table's content if no other DIR attribute applies to that
480 text.
481
482 Horizontal and Vertical Alignment Attributes
483
484 The alignment of cell contents can be specified on a cell by cell
485 basis, or inherited from enclosing elements, such as the row, column
486 or the table element itself.
487
488 ALIGN
489 This specifies the horizontal alignment of cell contents.
490
491 <!-- horizontal alignment attributes for cell contents -->
492 <!ENTITY % cell.halign
493 "align (left|center|right|justify|char) #IMPLIED
494 char CDATA #IMPLIED -- alignment char, e.g. char=':' --
495 charoff CDATA #IMPLIED -- offset for alignment char --"
496 >
497
498 The attribute value should be one of LEFT, CENTER, RIGHT,
499 JUSTIFY and CHAR. User agents may treat JUSTIFY as left
500 alignment if they lack support for text justification.
501 ALIGN=CHAR is used for aligning cell contents on a particular
502 character.
503
504
505
506 Raggett Experimental [Page 9]
507 \f
508 RFC 1942 HTML Tables May 1996
509
510
511 For cells spanning multiple rows or columns, where the alignment
512 property is inherited from the row or column, the initial row
513 and column for the cell determines the appropriate alignment
514 property to use.
515
516 Note that an alignment attribute on elements within the cell,
517 e.g. on a P element, overrides the normal alignment value for
518 the cell.
519
520 CHAR
521 This is used to specify an alignment character for use with
522 align=char, e.g. char=":". The default character is the decimal
523 point for the current language, as set by the LANG attribute.
524 The CHAR attribute value is case sensitive.
525
526 CHAROFF
527 Specifies the offset to the first occurrence of the alignment
528 character on each line. If a line doesn't include the alignment
529 character, it should be horizontally shifted to end at the
530 alignment position. The resolved direction of the cell, as
531 determined by the inheritance of the DIR attribute, is used to
532 set whether the offset is from the left or right margin of the
533 cell. For Latin scripts, the offset will be from the left
534 margin, while for Arabic scripts, it will be from the right
535 margin. In addition to standard units, the "%" sign may be used
536 to indicate that the value specifies the alignment position as a
537 percentage offset of the current cell, e.g. CHAROFF="30%"
538 indicates the alignment character should be positioned 30%
539 through the cell.
540
541 When using the two pass layout algorithm, the default alignment
542 position in the absence of an explicit or inherited CHAROFF
543 attribute can be determined by choosing the position that would
544 center lines for which the width before and after the alignment
545 character are at the maximum values for any of the lines in the
546 column for which ALIGN=CHAR. For incremental table layout the
547 suggested default is CHAROFF="50%". If several cells in
548 different rows for the same column use character alignment, then
549 by default, all such cells should line up, regardless of which
550 character is used for alignment. Rules for handling objects too
551 large for column apply when the explicit or implied alignment
552 results in a situation where the data exceeds the assigned width
553 of the column.
554
555 VALIGN
556 Defines whether the cell contents are aligned with the top,
557 middle or bottom of the cell.
558
559
560
561
562 Raggett Experimental [Page 10]
563 \f
564 RFC 1942 HTML Tables May 1996
565
566
567 <!-- vertical alignment attributes for cell contents -->
568 <!ENTITY % cell.valign
569 "valign (top|middle|bottom|baseline) #IMPLIED"
570 >
571
572 If present, the value of the attribute should be one of: TOP,
573 MIDDLE, BOTTOM or BASELINE. All cells in the same row with
574 valign=baseline should be vertically positioned so that the
575 first text line in each such cell occur on a common baseline.
576 This constraint does not apply to subsequent text lines in these
577 cells.
578
579 Inheritance Order
580
581 Alignment properties can be included with most of the table elements:
582 COL, THEAD, TBODY, TFOOT, TR, TH and TD. When rendering cells,
583 horizontal alignment is determined by columns in preference to rows,
584 while for vertical alignment, the rows are more important than the
585 columns. The following table gives the detailed precedence order for
586 each attribute, where X > Y denotes that X takes precedence over Y:
587
588 ALIGN, CHAR and CHAROFF:
589
590 cells > columns > column groups > rows > row groups > default
591
592 VALIGN, LANG, and DIR:
593
594 cells > rows > row groups > columns > column groups > table > default
595
596 Where cells are defined by TH and TD elements; rows by TR elements;
597 row groups by THEAD, TBODY and TFOOT elements, columns by COL
598 elements; and column groups by COLGROUP and COL elements. Note that
599 there is no inheritance mechanism for the CLASS attribute.
600
601 Properties defined on cells take precedence over inherited
602 properties, but are in turn over-ridden by alignment properties on
603 elements within cells. In the absence of an ALIGN attribute along the
604 inheritance path, the recommended default alignment for table cell
605 contents is ALIGN=LEFT for table data and ALIGN=CENTER for table
606 headers. The recommended default for vertical alignment is
607 VALIGN=MIDDLE. These defaults are chosen to match the behaviour of
608 the widely deployed Netscape implementation.
609
610 Standard Units for Widths
611
612 Several attributes specify widths as a number followed by an optional
613 suffix. The units for widths are specified by the suffix: pt denotes
614 points, pi denotes picas, in denotes inches, cm denotes centimeters,
615
616
617
618 Raggett Experimental [Page 11]
619 \f
620 RFC 1942 HTML Tables May 1996
621
622
623 mm denotes millimeters, em denotes em units (equal to the height of
624 the default font), and px denotes screen pixels. The default units
625 are screen pixels (chosen for backwards compatibility). The number is
626 an integer value or a real valued number such as "2.5". Exponents, as
627 in "1.2e2", are not allowed. White space is not allowed between the
628 number and the suffix.
629
630 The above set of suffices is augmented for certain elements: "%" is
631 used for the WIDTH attribute for the TABLE element. It indicates that
632 the attribute specifies the percentage width of the space between the
633 current left and right margins, e.g. width="50%". For the COL
634 element, "*" is used with the WIDTH attribute to specify relative
635 column widths, e.g. width="3*", using the same representation as the
636 CALS table model.
637
638 The TABLE element
639
640 <!ENTITY % Where "(left|center|right)">
641
642 <!ELEMENT table - - (caption?, (col*|colgroup*), thead?, tfoot?, tbody+)>
643
644 <!ATTLIST table -- table element --
645 %attrs; -- id, lang, dir and class --
646 align %Where; #IMPLIED -- table position relative to --
647 -- window --
648 width CDATA #IMPLIED -- table width relative to window --
649 cols NUMBER #IMPLIED -- used for immediate display mode --
650 border CDATA #IMPLIED -- controls frame width around --
651 -- table --
652 frame %Frame; #IMPLIED -- which parts of table frame to --
653 -- include --
654 rules %Rules; #IMPLIED -- controls rules between cells --
655 cellspacing CDATA #IMPLIED -- spacing between cells --
656 cellpadding CDATA #IMPLIED -- spacing within cells --
657 >
658
659 The TABLE element requires both start and end tags. Table elements
660 start with an optional CAPTION element, optionally followed by either
661 one or more COL elements, or one or more COLGROUP elements, then an
662 optional THEAD, an optional TFOOT, and finally one or more TBODY
663 elements.
664
665 ID, CLASS, LANG and DIR
666 See earlier description of common attributes.
667
668 ALIGN
669 Defines the horizontal position of the table relative to the
670 current left and right margins. ALIGN=CENTER centers the table
671
672
673
674 Raggett Experimental [Page 12]
675 \f
676 RFC 1942 HTML Tables May 1996
677
678
679 midway between the left and right margins. ALIGN=LEFT positions
680 the table at the left margin, while ALIGN=RIGHT positions the
681 table at the right margin. User agents may flow text around the
682 right handside of the table for ALIGN=LEFT, or the left handside
683 for ALIGN=RIGHT.
684
685 Note you can use <BR CLEAR=LEFT> after the table element if you
686 want to avoid text flowing along side the table when you have
687 specified ALIGN=LEFT, or <BR CLEAR=RIGHT> for a right aligned
688 table. To prevent a right aligned table flowing around something
689 else, use <BR CLEAR=RIGHT> before the table etc. Greater control
690 over textflow is possible using style sheets.
691
692 WIDTH
693 Specifies the desired width of the table. In addition to the
694 standard units, the "%" sign may used to indicate that the width
695 specifies the percentage width of the space between the current
696 left and right margins, e.g. width="50%". In the absence of this
697 attribute, the table width can be determined by the layout
698 algorithm given later on.
699
700 It is recommended that the table width be increased beyond the
701 value indicated by the WIDTH attribute as needed to avoid any
702 overflow of cell contents. Such increases should try to avoid
703 drastic changes to relative column widths specified by the
704 author. To avoid the need for excessive horizontal scrolling, or
705 when such scrolling is impractical or undesired, it may be
706 appropriate to split words across lines.
707
708 COLS
709 Specifies the number of columns for the table. If present the
710 user agent may render the table dynamically as data is received
711 from the network without waiting for the complete table to be
712 received. If the WIDTH attribute is missing, a default of "100%"
713 may be assumed for this purpose. If the COLS attribute is
714 absent, a prepass through the table's contents is needed to
715 determine the number of columns together with suitable values
716 for the widths of each column.
717
718 BORDER
719 Specifies the width of the border framing the table, see
720 standard units.
721
722 FRAME
723 Specifies which sides of the frame to render.
724
725 <!ENTITY % Frame
726 "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
727
728
729
730 Raggett Experimental [Page 13]
731 \f
732 RFC 1942 HTML Tables May 1996
733
734
735 VOID
736 Don't render any sides of the frame.
737
738 ABOVE
739 The top side of the frame
740
741 BELOW
742 The bottom side of the frame
743
744 HSIDES
745 The top and bottom sides of the frame
746
747 LHS
748 The left hand side of the frame
749
750 RHS
751 The right hand side of the frame
752
753 VSIDES
754 The left and right sides of the frame
755
756 BOX
757 All four sides of the frame
758
759 BORDER
760 All four sides of the frame
761
762 The value "Border" is included for backwards compatibility with
763 deployed browsers. If a document includes <TABLE BORDER> the
764 user agent will see FRAME=BORDER and BORDER=_implied_. If the
765 document includes <TABLE BORDER=_n_> then the user agent should
766 treat this as FRAME=BORDER except if _n=0_ for which FRAME=VOID
767 is appropriate.
768
769 Note: it would have been preferable to choose values for FRAME
770 consistent with the RULES attribute and the values used for
771 alignment. For instance: none, top, bottom, topbot, left, right,
772 leftright, all. Unfortunately, SGML requires enumerated
773 attribute values to be unique for each element, independent of
774 the attribute name. This causes immediate problems for "none",
775 "left", "right" and "all". The values for FRAME have been chosen
776 to avoid clashes with the RULES, ALIGN and VALIGN attributes.
777 This provides a measure of future proofing, as it is anticipated
778 that that the FRAME and RULES attributes will be added to other
779 table elements in future revisions to this specification. An
780 alternative would be to make FRAME a CDATA attribute. The
781 consensus of the HTML-WG was that the benefits of being able to
782 use SGML validation tools to check attributes based on
783
784
785
786 Raggett Experimental [Page 14]
787 \f
788 RFC 1942 HTML Tables May 1996
789
790
791 enumerated values outweighs the need for consistent names.
792
793 RULES
794 Specifies where to draw rules within the table interior.
795
796 <!ENTITY % Rules "(none | groups | rows | cols | all)">
797
798 NONE
799 Suppresses internal rulings.
800
801 GROUPS
802 The THEAD, TFOOT and TBODY elements divide the table into
803 groups of rows, while COLGROUP elements divide the table
804 into groups of columns. This choice places a horizontal rule
805 between each row group and a vertical rule between each
806 column group. Note that every table has at least one row and
807 one column group.
808
809 ROWS
810 As RULES=GROUPS plus horizontal rules between all rows. User
811 agents may choose to use a heavier rule between groups of
812 rows and columns for emphasis.
813
814 COLS
815 As RULES=GROUPS plus vertical rules between all columns.
816 User agents may choose to use a heavier rule between groups
817 of rows and columns for emphasis.
818
819 ALL
820 Place rules between all rows and all columns. User agents
821 may choose to use a heavier rule between groups of rows and
822 columns for emphasis.
823
824 If a document includes <TABLE BORDER> or <TABLE BORDER=_n_> then
825 the default for the table element is RULES=ALL, except if _n=0_
826 for which RULES=NONE is appropriate.
827
828 CELLSPACING
829 This attribute is intended for backwards compatibility with
830 deployed user agents. It specifies the space between the table
831 frame and the first or last cell border for each row or column,
832 and between other cells in the table. See standard units.
833 Greater control will be possible using style sheet languages.
834
835 CELLPADDING
836 This attribute is intended for backwards compatibility with
837 deployed user agents. It specifies the amount of space between
838 the border of the cell and its contents both above/below, and
839
840
841
842 Raggett Experimental [Page 15]
843 \f
844 RFC 1942 HTML Tables May 1996
845
846
847 left//right. See standard units. Greater control will be
848 possible using style sheet languages.
849
850 If a fixed width is set for the table or column, the CELLSPACING and
851 CELLPADDING may demand more space than assigned. Current practice is
852 for the latter to take precedence over WIDTH attributes when a
853 conflict occurs, although this isn't required by this specification.
854
855 Table Captions
856
857 <!ELEMENT caption - - (%text;)+>
858
859 <!ENTITY % Caption "(top|bottom|left|right)">
860
861 <!ATTLIST caption -- table caption --
862 %attrs; -- id, lang, dir and class --
863 align %Caption; #IMPLIED -- relative to table --
864 >
865
866 The optional CAPTION element is used to provide a caption for the
867 table. Both start and end tags are required.
868
869 ID, CLASS, LANG and DIR
870 See earlier description of common attributes.
871
872 ALIGN
873 This may be used to control the placement of captions relative
874 to the table. When present, the ALIGN attribute should have one
875 of the values: TOP, BOTTOM, LEFT and RIGHT. It is recommended
876 that the caption is made to fit within the width or height of
877 the table as appropriate. The default position of the caption is
878 deliberately unspecified.
879
880 Note the ALIGN attribute is overused in HTML, but is retained
881 here for compatibility with currently deployed browsers.
882
883 The COLGROUP Element
884
885 <!ELEMENT colgroup - O (col*)>
886
887 <!ATTLIST colgroup
888 %attrs; -- id, lang, dir and class --
889 span NUMBER 1 -- default number of columns in --
890 -- group --
891 width CDATA #IMPLIED -- default width for enclosed --
892 -- COLs --
893 %cell.halign; -- horizontal alignment in --
894 -- cells --
895
896
897
898 Raggett Experimental [Page 16]
899 \f
900 RFC 1942 HTML Tables May 1996
901
902
903 %cell.valign; -- vertical alignment in cells --
904 >
905
906
907 The COLGROUP element acts as a container for a group of columns, and
908 allows you to set default properties for these columns. In the
909 absence of a COLGROUP element, all columns in the table are assumed
910 to belong to a single column group. Each COLGROUP element can
911 contain zero or more COL elements. COLGROUP requires a start tag,
912 but the end tag may be omitted. This is useful when defining a
913 sequence of COLGROUP elements, e.g.
914
915 <TABLE FRAME=BOX RULES=COLS>
916 <COLGROUP>
917 <COL WIDTH="1*">
918 <COL WIDTH="2*">
919 <COLGROUP>
920 <COL WIDTH="1*">
921 <COL WIDTH="3*">
922 <THEAD>
923 <TR> ...
924 </TABLE>
925
926 COLGROUP elements can be used with the following attributes:
927
928 ID, CLASS, LANG and DIR
929 See earlier description of common attributes.
930
931 SPAN
932 A positive integer value that specifies a default for how many
933 columns are in this group. This attribute should be ignored if
934 the COLGROUP element contains one or more COL elements. It
935 provides a convenient way of grouping columns without the need
936 to supply COL elements.
937
938 WIDTH
939 Specifies a default width for each of the grouped columns, see
940 standard units. In addition, the "*" suffix denotes relative
941 widths, e.g.
942
943 width=64 width in screen pixels
944 width=0.5* a relative width of 0.5
945
946 Relative widths act as constraints on the relative widths of
947 different columns. If a COLGROUP element specifies a relative
948 width of zero, all of the columns in the group should be set to
949 their minimum widths, unless they are associated with a COL
950 element with an overriding WIDTH attribute. When widths are
951
952
953
954 Raggett Experimental [Page 17]
955 \f
956 RFC 1942 HTML Tables May 1996
957
958
959 given in absolute units, the user agent can use these to
960 constrain the width of the table. The "*" suffix is used to
961 simplify importing tables from the CALS representation.
962
963 ALIGN, CHAR, CHAROFF and VALIGN
964 Specify values for horizontal and vertical alignment within
965 table cells. See inheritance order of alignment properties.
966
967 The COL Element
968
969 <!ELEMENT col - O EMPTY>
970
971 <!ATTLIST col -- column groups and --
972 -- properties --
973 %attrs; -- id, lang, dir and class --
974 span NUMBER 1 -- number of columns spanned --
975 -- by group --
976 width CDATA #IMPLIED -- column width specification --
977 %cell.halign; -- horizontal alignment in --
978 -- cells --
979 %cell.valign; -- vertical alignment in cells --
980 >
981
982 This optional element is used to specify column based defaults for
983 table properties. It is an empty element, and as such has no
984 content, and shouldn't be given an end tag. Several COL elements may
985 be given in succession. COL attributes override those of the parent
986 COLGROUP element.
987
988 ID, CLASS, LANG and DIR
989 See earlier description of common attributes.
990
991 SPAN
992 A positive integer value that specifies how many columns this
993 element applies to, defaulting to one. In the absence of SPAN
994 attributes the first COL element applies to the first column,
995 the second COL element to the second column and so on. If the
996 second COL element had SPAN=2, it would apply to the second and
997 third column. The next COL element would then apply to the
998 fourth column and so on. SPAN=0 has a special significance and
999 implies that the COL element spans all columns from the current
1000 column up to and including the last column. Note that a COL SPAN
1001 does not define a group. It is merely a way to share attribute
1002 definitions.
1003
1004
1005
1006
1007
1008
1009
1010 Raggett Experimental [Page 18]
1011 \f
1012 RFC 1942 HTML Tables May 1996
1013
1014
1015 WIDTH
1016 Specifies the width of the columns, see standard units. If the
1017 element spans several columns then the WIDTH attribute specifies
1018 the width for each of the individual columns - not the width of
1019 the span. In addition, the "*" suffix denotes relative widths,
1020
1021 e.g.
1022
1023 width=64 width in screen pixels
1024 width=0.5* a relative width of 0.5
1025
1026 Relative widths act as constraints on the relative widths of
1027 different columns. If a COL element specifies a relative width
1028 of zero, the column should always be set to its minimum width.
1029 When widths are given in absolute units, the user agent can use
1030 these to constrain the width of the table. The "*" suffix is
1031 used to simplify importing tables from the CALS representation.
1032
1033 ALIGN, CHAR, CHAROFF and VALIGN
1034 Specify values for horizontal and vertical alignment within
1035 table cells. See inheritance order of alignment properties.
1036
1037 Table Head, Foot and Body Elements
1038
1039 <!ELEMENT thead - O tr+>
1040 <!ELEMENT tfoot - O tr+>
1041 <!ELEMENT tbody O O tr+>
1042
1043 <!ATTLIST (thead|tbody|tfoot) -- table section --
1044 %attrs; -- id, lang, dir and class --
1045 %cell.halign; -- horizontal alignment in --
1046 -- cells --
1047 %cell.valign; -- vertical alignment in cells --
1048 >
1049
1050 Tables may be divided up into head and body sections. The THEAD and
1051 TFOOT elements are optional, but one or more TBODY elements are
1052 always required. If the table only consists of a TBODY section, the
1053 TBODY start and end tags may be omitted, as the parser can infer
1054 them. If a THEAD element is present, the THEAD start tag is
1055 required, but the end tag can be omitted, provided a TFOOT or TBODY
1056 start tag follows. The same applies to TFOOT.
1057
1058 Note: This definition provides compatibility with tables created
1059 for the older model, as well as allowing the end tags for THEAD,
1060 TFOOT and TBODY to be omitted.
1061
1062
1063
1064
1065
1066 Raggett Experimental [Page 19]
1067 \f
1068 RFC 1942 HTML Tables May 1996
1069
1070
1071 The THEAD, TFOOT and TBODY elements provide a convenient means for
1072 controlling rendering. If the table has a large number of rows in
1073 the body, user agents may choose to use a scrolling region for the
1074 table body sections. When rendering to a paged device, tables will
1075 often have to be broken across page boundaries. The THEAD, TFOOT and
1076 TBODY elements allow the user agent to repeat the table foot at the
1077 bottom of the current page, and then the table head at the top of
1078 the new page before continuing on with the table body.
1079
1080 TFOOT is placed before the TBODY in the markup sequence, so that
1081 browsers can render the foot before receiving all of the table data.
1082 This is useful when very long tables are rendered with scrolling
1083 body sections, or for paged output, involving breaking the table
1084 over many pages.
1085
1086 Each THEAD, TFOOT and TBODY element must contain one or more TR
1087 elements.
1088
1089 ID, CLASS, LANG and DIR
1090 See earlier description of common attributes.
1091
1092 ALIGN, CHAR, CHAROFF and VALIGN
1093 Specify values for horizontal and vertical alignment within
1094 table cells. See inheritance order of alignment properties.
1095
1096 Table Row (TR) elements
1097
1098 <!ELEMENT tr - O (th|td)+>
1099
1100 <!ATTLIST tr -- table row --
1101 %attrs; -- id, lang, dir and class --
1102 %cell.halign; -- horizontal alignment in --
1103 -- cells --
1104 %cell.valign; -- vertical alignment in cells --
1105 >
1106
1107 The TR or table row element acts as a container for a row of table
1108 cells. The end tag may be omitted.
1109
1110 ID, CLASS, LANG and DIR
1111 See earlier description of common attributes.
1112
1113 ALIGN, CHAR, CHAROFF and VALIGN
1114 Specify values for horizontal and vertical alignment within
1115 table cells. See inheritance order of alignment properties.
1116
1117
1118
1119
1120
1121
1122 Raggett Experimental [Page 20]
1123 \f
1124 RFC 1942 HTML Tables May 1996
1125
1126
1127 Table Cells: TH and TD
1128
1129 <!ELEMENT (th|td) - O %body.content>
1130
1131 <!ATTLIST (th|td) -- header or data cell --
1132 %attrs; -- id, lang, dir and class --
1133 axis CDATA #IMPLIED -- defaults to cell content --
1134 axes CDATA #IMPLIED -- list of axis names --
1135 nowrap (nowrap) #IMPLIED -- suppress word wrap --
1136 rowspan NUMBER 1 -- number of rows spanned by --
1137 -- cell --
1138 colspan NUMBER 1 -- number of cols spanned by --
1139 -- cell --
1140 %cell.halign; -- horizontal alignment in --
1141 -- cells --
1142 %cell.valign; -- vertical alignment in cells --
1143 >
1144
1145 TH elements are used to represent header cells, while TD elements
1146 are used to represent data cells. This allows user agents to render
1147 header and data cells distinctly, even in the absence of style
1148 sheets.
1149
1150 Cells can span multiple rows and columns, and may be empty. Cells
1151 spanning rows contribute to the column count on each of the spanned
1152 rows, but only appear in the markup once (in the first row spanned).
1153 The row count is determined by the number of TR elements. Any rows
1154 implied by cells spanning rows beyond this should be ignored.
1155
1156 If the column count for the table is greater than the number of
1157 cells for a given row (after including cells for spanned rows), the
1158 missing cells are treated as occurring on the right hand side of the
1159 table and rendered as empty cells. If the language context indicates
1160 a right to left writing order, then the missing cells should be
1161 placed on the left hand side.
1162
1163 It is possible to create tables with overlapping cells, for
1164 instance:
1165
1166 <table border>
1167 <tr><td rowspan=2>1<td>2<td>3
1168 <tr><td rowspan=2>4
1169 <tr><td colspan=2>5<td>6
1170 </table>
1171
1172
1173
1174
1175
1176
1177
1178 Raggett Experimental [Page 21]
1179 \f
1180 RFC 1942 HTML Tables May 1996
1181
1182
1183 which might look something like:
1184
1185 /-----------\
1186 | 1 | 2 | 3 |
1187 | |-------|
1188 | | 4 | |
1189 |---|...|---|
1190 | 5 : | 6 |
1191 \-----------/
1192
1193 In this example, the cells labelled 4 and 5 overlap. In such cases,
1194 the rendering is implementation dependent.
1195
1196 The AXIS and AXES attributes for cells provide a means for defining
1197 concise labels for cells. When rendering to speech, these attributes
1198 may be used to provide abbreviated names for the headers relevant to
1199 each cell. Another application is when you want to be able to later
1200 process table contents to enter them into a database. These
1201 attributes are then used to give database field names. The table's
1202 class attribute should be used to let the software recognize which
1203 tables can be treated in this way.
1204
1205 ID, CLASS, LANG and DIR
1206 See earlier description of common attributes.
1207
1208 AXIS
1209 This defines an abbreviated name for a header cell, e.g. which
1210 can be used when rendering to speech. It defaults to the cell's
1211 content.
1212
1213 AXES
1214 This is a comma separated list of axis names which together
1215 identify the row and column headers that pertain to this cell.
1216 It is used for example when rendering to speech to identify the
1217 cell's position in the table. If missing the user agent can try
1218 to follow up columns and left along rows (right for some
1219 languages) to find the corresponding header cells.
1220
1221 NOWRAP, e.g. <TD NOWRAP>
1222 The presence of this attribute disables automatic wrapping of
1223 text lines for this cell. If used uncautiously, it may result in
1224 excessively wide cells. This attribute is defined for backwards
1225 compatibility with deployed user agents. Greater control is
1226 possible with associated style sheet languages (for example for
1227 control over overflow handling).
1228
1229
1230
1231
1232
1233
1234 Raggett Experimental [Page 22]
1235 \f
1236 RFC 1942 HTML Tables May 1996
1237
1238
1239 ROWSPAN, e.g. <TD ROWSPAN=2>
1240 A positive integer value that defines how may rows this cell
1241 spans. The default ROWSPAN is 1. ROWSPAN=0 has a special
1242 significance and implies that the cell spans all rows from the
1243 current row up to the last row of the table.
1244
1245 COLSPAN, e.g. <TD COLSPAN=2>
1246 A positive integer value that defines how may columns this cell
1247 spans. The default COLSPAN is 1. COLSPAN=0 has a special
1248 significance and implies that the cell spans all columns from
1249 the current column up to the last column of the table.
1250
1251 ALIGN, CHAR, CHAROFF and VALIGN
1252 Specify values for horizontal and vertical alignment within
1253 table cells. See inheritance order of alignment properties.
1254
1255 Note: It is recommended that implementors provide support for the
1256 Netscape 1.1 WIDTH attribute for TH and TD, although this isn't part
1257 of the current specification. Document authors are advised to use
1258 the width attribute for the COL element instead.
1259
1260 Recommended Layout Algorithms
1261
1262 If the COLS attribute on the TABLE element specifies the number of
1263 columns, then the table may be rendered using a fixed layout,
1264 otherwise the autolayout algorithm described below should be used.
1265
1266 Fixed Layout Algorithm
1267
1268 For this algorithm, it is assumed that the number of columns is
1269 known. The column widths by default should be set to the same size.
1270 Authors may override this by specifying relative or absolute column
1271 widths, using the COLGROUP or COL elements. The default table width
1272 is the space between the current left and right margins, but may be
1273 overridden by the WIDTH attribute on the TABLE element, or determined
1274 from absolute column widths. To deal with mixtures of absolute and
1275 relative column widths, the first step is to allocate space from the
1276 table width to columns with absolute widths. After this, the space
1277 remaining is divided up between the columns with relative widths.
1278
1279 The table syntax alone is insufficient to guarantee the consistency
1280 of attribute values. For instance, the number of columns specified by
1281 the COLS attribute may be inconsistent with the number of columns
1282 implied by the COL elements. This in turn, may be inconsistent with
1283 the number of columns implied by the table cells. A further problem
1284 occurs when the columns are too narrow to avoid overflow of cell
1285 contents. The width of the table as specified by the TABLE element or
1286 COL elements may result in overflow of cell contents. It is
1287
1288
1289
1290 Raggett Experimental [Page 23]
1291 \f
1292 RFC 1942 HTML Tables May 1996
1293
1294
1295 recommended that user agents attempt to recover gracefully from these
1296 situations, e.g. by hyphenating words and resorting to splitting
1297 words if hyphenation points are unknown.
1298
1299 In the event that an indivisible element causes cell overflow, the
1300 user agent may consider adjusting column widths and re-rendering the
1301 table. In the worst case clipping may be considered if column width
1302 adjustments and/or scrollable cell content are not feasible. In any
1303 case if cell content is split or clipped this should be indicated to
1304 the user in an appropriate manner.
1305
1306 Autolayout Algorithm
1307
1308 If the COLS attribute is missing from the table start tag, then the
1309 user agent should use the following autolayout algorithm. It uses two
1310 passes through the table data and scales linearly with the size of
1311 the table.
1312
1313 In the first pass, line wrapping is disabled, and the user agent
1314 keeps track of the minimum and maximum width of each cell. The
1315 maximum width is given by the widest line. As line wrap has been
1316 disabled, paragraphs are treated as long lines unless broken by <BR>
1317 elements. The minimum width is given by the widest word or image etc.
1318 taking into account leading indents and list bullets etc. In other
1319 words, if you were to format the cell's content in a window of its
1320 own, determine the minimum width you could make the window before the
1321 cell begins to overflow. Allowing user agents to split words will
1322 minimize the need for horizontal scrolling or in the worst case
1323 clipping of cell contents.
1324
1325 This process also applies to any nested tables occuring in cell
1326 content. The minimum and maximum widths for cells in nested tables
1327 are used to determine the minimum and maximum widths for these tables
1328 and hence for the parent table cell itself. The algorithm is linear
1329 with aggregate cell content, and broadly speaking independent of the
1330 depth of nesting.
1331
1332 To cope with character alignment of cell contents, the algorithm
1333 keeps three running min/max totals for each column: Left of align
1334 char, right of align char and un-aligned. The minimum width for a
1335 column is then: max(min_left + min_right, min_non-aligned).
1336
1337 The minimum and maximum cell widths are then used to determine the
1338 corresponding minimum and maximum widths for the columns. These in
1339 turn, are used to find the minimum and maximum width for the table.
1340 Note that cells can contain nested tables, but this doesn't
1341 complicate the code significantly. The next step is to assign column
1342 widths according to the available space (i.e. the space between the
1343
1344
1345
1346 Raggett Experimental [Page 24]
1347 \f
1348 RFC 1942 HTML Tables May 1996
1349
1350
1351 current left and right margins).
1352
1353 For cells which span multiple columns, a simple approach, as used by
1354 Arena, is to evenly apportion the min/max widths to each of the
1355 constituent columns. A slightly more complex approach is to use the
1356 min/max widths of unspanned cells to weight how spanned widths are
1357 apportioned. Experimental study suggests a blend of the two
1358 approaches will give good results for a wide range of tables.
1359
1360 The table borders and intercell margins need to be included in
1361 assigning column widths. There are three cases:
1362
1363 1. The minimum table width is equal to or wider than the available
1364 space. In this case, assign the minimum widths and allow the
1365 user to scroll horizontally. For conversion to braille, it will
1366 be necessary to replace the cells by references to notes
1367 containing their full content. By convention these appear before
1368 the table.
1369
1370 2. The maximum table width fits within the available space. In this
1371 case, set the columns to their maximum widths.
1372
1373 3. The maximum width of the table is greater than the available
1374 space, but the minimum table width is smaller. In this case,
1375 find the difference between the available space and the minimum
1376 table width, lets call it W. Lets also call D the difference
1377 between maximum and minimum width of the table.
1378
1379 For each column, let d be the difference between maximum and
1380 minimum width of that column. Now set the column's width to the
1381 minimum width plus d times W over D. This makes columns with
1382 large differences between minimum and maximum widths wider than
1383 columns with smaller differences.
1384
1385 This assignment step is then repeated for nested tables using the
1386 minimum and maximum widths derived for all such tables in the first
1387 pass. In this case, the width of the parent (i.e. enclosing) table
1388 cell plays the role of the current window size in the above
1389 description. This process is repeated recursively for all nested
1390 tables. The topmost table is then rendered using the assigned widths.
1391 Nested tables are subsequently rendered as part of the parent table's
1392 cell contents.
1393
1394 If the table width is specified with the WIDTH attribute, the user
1395 agent attempts to set column widths to match. The WIDTH attribute is
1396 not binding if this results in columns having less than their minimum
1397 (i.e. indivisible) widths.
1398
1399
1400
1401
1402 Raggett Experimental [Page 25]
1403 \f
1404 RFC 1942 HTML Tables May 1996
1405
1406
1407 If relative widths are specified with the COL element, the algorithm
1408 is modified to increase column widths over the minimum width to meet
1409 the relative width constraints. The COL elements should be taken as
1410 hints only, so columns shouldn't be set to less than their minimum
1411 width. Similarly, columns shouldn't be made so wide that the table
1412 stretches well beyond the extent of the window. If a COL element
1413 specifies a relative width of zero, the column should always be set
1414 to its minimum width.
1415
1416 HTML Table DTD
1417
1418 The DTD or document type definition provides the formal definition of
1419 the allowed syntax for HTML tables.
1420
1421 <!-- Content model entities imported from parent DTD:
1422
1423 %body.content; allows table cells to contain headers, paras,
1424 lists, form elements and even arbitrarily nested tables.
1425
1426 %text; is text characters, including character entities and
1427 character emphasis elements, IMG and anchors
1428 -->
1429
1430 <!ENTITY % attrs
1431 "id ID #IMPLIED -- element identifier --
1432 class NAMES #IMPLIED -- for subclassing elements --
1433 lang NAME #IMPLIED -- as per RFC 1766 --
1434 dir (ltr|rtl) #IMPLIED -- I18N text direction --">
1435
1436 <!--
1437 The BORDER attribute sets the thickness of the frame around the
1438 table. The default units are screen pixels.
1439
1440 The FRAME attribute specifies which parts of the frame around
1441 the table should be rendered. The values are not the same as
1442 CALS to avoid a name clash with the VALIGN attribute.
1443
1444 The value "border" is included for backwards compatibility with
1445 <TABLE BORDER> which yields frame=border and border=implied
1446 For <TABLE BORDER=1> you get border=1 and frame=implied. In this
1447 case, its appropriate to treat this as frame=border for backwards
1448 compatibility with deployed browsers.
1449 -->
1450
1451 <!ENTITY % Frame "(void|above|below|hsides|lhs|rhs|vsides|box|border)">
1452
1453
1454
1455
1456
1457
1458 Raggett Experimental [Page 26]
1459 \f
1460 RFC 1942 HTML Tables May 1996
1461
1462
1463 <!--
1464 The RULES attribute defines which rules to draw between cells:
1465
1466 If RULES is absent then assume:
1467 "none" if BORDER is absent or BORDER=0 otherwise "all"
1468 -->
1469
1470 <!ENTITY % Rules "(none | groups | rows | cols | all)">
1471
1472 <!-- horizontal placement of table relative to window -->
1473 <!ENTITY % Where "(left|center|right)">
1474
1475 <!-- horizontal alignment attributes for cell contents -->
1476 <!ENTITY % cell.halign
1477 "align (left|center|right|justify|char) #IMPLIED
1478 char CDATA #IMPLIED -- alignment char, e.g. char=':' --
1479 charoff CDATA #IMPLIED -- offset for alignment char --"
1480 >
1481
1482 <!-- vertical alignment attributes for cell contents -->
1483 <!ENTITY % cell.valign
1484 "valign (top|middle|bottom|baseline) #IMPLIED"
1485 >
1486
1487 <!ELEMENT table - - (caption?, (col*|colgroup*), thead?, tfoot?, t
1488 body+)>
1489 <!ELEMENT caption - - (%text;)+>
1490 <!ELEMENT thead - O (tr+)>
1491 <!ELEMENT tfoot - O (tr+)>
1492 <!ELEMENT tbody O O (tr+)>
1493 <!ELEMENT colgroup - O (col*)>
1494 <!ELEMENT col - O EMPTY>
1495 <!ELEMENT tr - O (th|td)+>
1496 <!ELEMENT (th|td) - O %body.content>
1497
1498 <!ATTLIST table -- table element --
1499 %attrs; -- id, lang, dir and class --
1500 align %Where; #IMPLIED -- table position relative to --
1501 -- window --
1502 width CDATA #IMPLIED -- table width relative to window --
1503 cols NUMBER #IMPLIED -- used for immediate display mode --
1504 border CDATA #IMPLIED -- controls frame width around --
1505 -- table --
1506 frame %Frame; #IMPLIED -- which parts of table frame to --
1507 -- include --
1508 rules %Rules; #IMPLIED -- rulings between rows and cols --
1509 cellspacing CDATA #IMPLIED -- spacing between cells --
1510 cellpadding CDATA #IMPLIED -- spacing within cells --
1511
1512
1513
1514 Raggett Experimental [Page 27]
1515 \f
1516 RFC 1942 HTML Tables May 1996
1517
1518
1519 >
1520
1521 <!-- ALIGN is used here for compatibility with deployed browsers -->
1522 <!ENTITY % Caption "(top|bottom|left|right)">
1523
1524 <!ATTLIST caption -- table caption --
1525 %attrs; -- id, lang, dir and class --
1526 align %Caption; #IMPLIED -- relative to table --
1527 >
1528
1529 <!--
1530 COLGROUP groups a set of COL elements. It allows you to group
1531 several columns together.
1532 -->
1533 <!ATTLIST colgroup
1534 %attrs; -- id, lang, dir and class --
1535 span NUMBER 1 -- default number of columns in --
1536 -- group --
1537 width CDATA #IMPLIED -- default width for enclosed COLs --
1538 %cell.halign; -- horizontal alignment in cells --
1539 %cell.valign; -- vertical alignment in cells --
1540 >
1541
1542 <!--
1543 COL elements define the alignment properties for cells in a given
1544 column or spanned columns. The WIDTH attribute specifies the
1545 width of the columns, e.g.
1546
1547 width=64 width in screen pixels
1548 width=0.5* relative width of 0.5
1549 -->
1550
1551 <!ATTLIST col -- column groups and properties --
1552 %attrs; -- id, lang, dir and class --
1553 span NUMBER 1 -- number of columns spanned by --
1554 -- group --
1555 width CDATA #IMPLIED -- column width specification --
1556 %cell.halign; -- horizontal alignment in cells --
1557 %cell.valign; -- vertical alignment in cells --
1558 >
1559
1560 <!--
1561 Use THEAD to duplicate headers when breaking table
1562 across page boundaries, or for static headers when
1563 body sections are rendered in scrolling panel.
1564
1565 Use TFOOT to duplicate footers when breaking table
1566 across page boundaries, or for static footers when
1567
1568
1569
1570 Raggett Experimental [Page 28]
1571 \f
1572 RFC 1942 HTML Tables May 1996
1573
1574
1575 body sections are rendered in scrolling panel.
1576
1577 Use multiple TBODY sections when rules are needed
1578 between groups of table rows.
1579 -->
1580 <!ATTLIST (thead|tbody|tfoot) -- table section --
1581 %attrs; -- id, lang, dir and class --
1582 %cell.halign; -- horizontal alignment in cells --
1583 %cell.valign; -- vertical alignment in cells --
1584 >
1585
1586 <!ATTLIST tr -- table row --
1587 %attrs; -- id, lang, dir and class --
1588 %cell.halign; -- horizontal alignment in cells --
1589 %cell.valign; -- vertical alignment in cells --
1590 >
1591
1592 <!ATTLIST (th|td) -- header or data cell --
1593 %attrs; -- id, lang, dir and class --
1594 axis CDATA #IMPLIED -- defaults to cell content --
1595 axes CDATA #IMPLIED -- list of axis names --
1596 nowrap (nowrap) #IMPLIED -- suppress word wrap --
1597 rowspan NUMBER 1 -- number of rows spanned by cell --
1598 colspan NUMBER 1 -- number of cols spanned by cell --
1599 %cell.halign; -- horizontal alignment in cells --
1600 %cell.valign; -- vertical alignment in cells --
1601 >
1602
1603 References
1604
1605 Arena
1606 W3C's HTML3 browser, see http://www.w3.org/pub/WWW/Arena/.
1607 Arena was originally created as a proof of concept demo for
1608 ideas in the HTML+ specification that preceded HTML3. The
1609 browser is now being re-implemented to provide a reference
1610 implementation of HTML3 along with support for style sheets and
1611 client-side scripting.
1612
1613 CALS
1614 Continuous Acquisition and Life-Cycle Support (formerly
1615 Computer-aided Acquisition and Logistics Support) (CALS) is a
1616 Department of Defense (DoD) strategy for achieving effective
1617 creation, exchange, and use of digital data for weapon systems
1618 and equipment. More information can be found from the US Navy
1619 CALS home page at http://navysgml.dt.navy.mil/cals.html
1620
1621
1622
1623
1624
1625
1626 Raggett Experimental [Page 29]
1627 \f
1628 RFC 1942 HTML Tables May 1996
1629
1630
1631 HTML 2.0 (RFC1866)
1632 Hypertext Markup Language Specification Version 2.0 by T.
1633 Berners-Lee and D. Connolly, November 1995. Further information
1634 can be found at http://www.w3.org/pub/WWW/MarkUp/ or at
1635 ftp://ds.internic.net/rfc/rfc1866.txt
1636
1637 HTML 3.0
1638 Hypertext Markup Language Specification Version 3.0. The initial
1639 draft specification as published in March 1995. Work on refining
1640 HTML3 is proceeding piecemeal with the new table specification
1641 as one of the pieces. For W3C related work on HTML, see
1642 http://www.w3.org/pub/WWW/MarkUp/.
1643
1644 RFC 1766
1645 "Tags for the Identification of Languages", by H. Alvestrand,
1646 UNINETT, March 1995. This document can be downloaded from
1647 ftp://ds.internic.net/rfc/rfc1766.txt.
1648
1649 Security Considerations
1650
1651 Security issues are not discussed in this memo.
1652
1653 Author's Address
1654
1655 Dave Raggett W3C
1656
1657 EMail: dsr@w3.org
1658
1659 The World Wide Web Consortium: http://www.w3.org/
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682 Raggett Experimental [Page 30]
1683 \f