W3C home > Mailing lists > Public > www-talk@w3.org > January to February 1997

Re: A table with fixed width?

From: Fabio Preda <preda@italtel.it>
Date: Thu, 30 Jan 1997 14:22:30 +0100
Message-Id: <32F0A096.99E@italtel.it>
To: Maurizio Codogno <mau@beatles.cselt.stet.it>
Cc: www-talk@www10.w3.org
Maurizio Codogno wrote:
> 
> I need a table with fixed width, say 22cm .
> I thought that <TABLE WIDTH=22cm> would have worked, but it turns not
> to be the case, at least with Netscape 3.01 for Solaris.
> WIDTH="22cm" does not work too, and I am not allowed to put whitespace
> as for RFC1942. What should I do?
> 
> .mau.

Hi
For the table size, you have to specify the width in percentage or in
pixel;
in the following lines I have included the table section about....

HTML 3.2 Reference Specification of W3C Recommendation 14-Jan-1997
(Author: Dave Raggett <dsr@w3.org>)

bye
F. Preda
------------------------------------------------------------------

.........

Tables

HTML 3.2 includes a widely deployed subset of the specification given in
RFC
1942 and can be used to markup tabular material or for layout purposes.
Note
that the latter role typically causes problems when rending to speech or
to
text only user agents.

<!-- horizontal placement of table relative to window -->
<!ENTITY % Where "(left|center|right)">

<!-- horizontal alignment attributes for cell contents -->
<!ENTITY % cell.halign
        "align  (left|center|right) #IMPLIED"
        >

<!-- vertical alignment attributes for cell contents -->
<!ENTITY % cell.valign
        "valign  (top|middle|bottom)  #IMPLIED"
        >

<!ELEMENT table - - (caption?, tr+)>
<!ELEMENT tr - O (th|td)*>
<!ELEMENT (th|td) - O %body.content>

<!ATTLIST table                       -- table element --
        align     %Where;   #IMPLIED  -- table position relative to
window --
        width     %Length   #IMPLIED  -- table width relative to window
--
        border    %Pixels   #IMPLIED  -- controls frame width around
table --
        cellspacing %Pixels #IMPLIED  -- spacing between cells --
        cellpadding %Pixels #IMPLIED  -- spacing within cells --
        >

<!ELEMENT CAPTION - - (%text;)* -- table or figure caption -->
<!ATTLIST CAPTION
        align (top|bottom) #IMPLIED
        >

<!ATTLIST tr                       -- table row --
        %cell.halign;              -- horizontal alignment in cells --
        %cell.valign;              -- vertical alignment in cells --
        >

<!ATTLIST (th|td)                  -- header or data cell --
        nowrap (nowrap)  #IMPLIED  -- suppress word wrap --
        rowspan NUMBER   1         -- number of rows spanned by cell --
        colspan NUMBER   1         -- number of cols spanned by cell --
        %cell.halign;              -- horizontal alignment in cells --
        %cell.valign;              -- vertical alignment in cells --
        width   %Pixels  #IMPLIED  -- suggested width for cell --
        height  %Pixels  #IMPLIED  -- suggested height for cell --
        >

Tables take the general form:
  <TABLE BORDER=3 CELLSPACING=2 CELLPADDING=2 WIDTH="80%">
  <CAPTION> ... table caption ... </CAPTION>
  <TR><TD> first cell <TD> second cell
  <TR> ...
  ...
  </TABLE>

The attributes on TABLE are all optional. By default, the table is
rendered
without a surrounding border. The table is generally sized automatically
to
fit the contents, but you can also set the table width using the WIDTH
attribute. BORDER, CELLSPACING and CELLPADDING provide further control
over
the table's appearence. Captions are rendered at the top or bottom of
the
table depending on the ALIGN attribute.

Each table row is contained in a TR element, although the end tag can
always
be omitted. Table cells are defined by TD elements for data and TH
elements
for headers. Like TR, these are containers and can be given without
trailing
end tags. TH and TD support several attributes: ALIGN and VALIGN for
aligning cell content, ROWSPAN and COLSPAN for cells which span more
than
one row or column. A cell can contain a wide variety of other block and
text
level elements including form fields and other tables.

The TABLE element always requires both start and end tags. It supports
the
following attributes:

align
     This takes one of the case insensitive values: LEFT, CENTER or
RIGHT.
     It specifies the horizontal placement of the table relative to the
     current left and right margins. It defaults to left alignment, but
this
     can be overridden by an enclosing DIV or CENTER element.
width
     In the absence of this attribute the table width is automatically
     determined from the table contents. You can use the WIDTH attribute
to
     set the table width to a fixed value in pixels (e.g. WIDTH=212) or
as a
     percentage of the space between the current left and right margins
     (e.g. WIDTH="80%").
border
     This attribute can be used to specify the width of the outer border
     around the table to a given number of pixels (e.g. BORDER=4). The
value
     can be set to zero to suppress the border altogether. In the
absence of
     this attribute the border should be suppressed. Note that some
browsers
     also accept <TABLE BORDER> with the same semantics as BORDER=1.
cellspacing
     In traditional desktop publishing software, adjacent table cells
share
     a common border. This is not the case in HTML. Each cell is given
its
     own border which is separated from the borders around neighboring
     cells. This separation can be set in pixels using the CELLSPACING
     attribute, (e.g. CELLSPACING=10). The same value also determines
the
     separation between the table border and the borders of the
outermost
     cells.
cellpadding
     This sets the padding in pixels between the border around each cell
and
     the cell's contents.

The CAPTION element has one attribute ALIGN which can be either
ALIGN=TOP or
ALIGN=BOTTOM. This can be used to force the caption to be placed above
the
top or below the bottom of the table respectively. Most user agents
default
to placing the caption above the table. CAPTION always requires both
start
and end tags. Captions are limited to plain text and text-level elements
as
defined by the %text entity. Block level elements are not permitted.

The TR or table row element requires a start tag, but the end tag can
always
be left out. TR acts as a container for table cells. It has two
attributes:

align
     Sets the default horizontal alignment of cell contents. It takes
one of
     the case insensitive values: LEFT, CENTER or RIGHT and plays the
same
     role as the ALIGN attribute on paragraph elements.
valign
     This can be used to set the default vertical alignment of cell
contents
     within each cell. It takes one of the case insensitive values: TOP,
     MIDDLE or BOTTOM to position the cell contents at the top, middle
or
     bottom of the cell respectively.

There are two elements for defining table cells. TH is used for header
cells
and TD for data cells. This distinction allows user agents to render
header
and data cells in different fonts, and enables speech based browsers to
do a
better job. The start tags for TH and TD are always needed but the end
tags
can be left out. Table cells can have the following attributes:

nowrap
     The presence of this attribute disables automatic word wrap within
the
     contents of this cell (e.g. <TD NOWRAP>). This is equivalent to
using
     the &nbsp; entity for non-breaking spaces within the content of the
     cell.
rowspan
     This takes a positive integer value specifying the number of rows
     spanned by this cell. It defaults to one.
colspan
     This takes a positive integer value specifying the number of
columns
     spanned by this cell. It defaults to one.
align
     Specifies the default horizontal alignment of cell contents, and
     overrides the ALIGN attribute on the table row. It takes the same
     values: LEFT, CENTER and RIGHT. If you don't specify an ALIGN
attribute
     value on the cell, the default is left alignment for <td> and
center
     alignment for <th> although you can override this with an ALIGN
     attribute on the TR element.
valign
     Specifies the default vertical alignment of cell contents,
overriding
     the VALIGN attribute on the table row. It takes the same values:
TOP,
     MIDDLE and BOTTOM. If you don't specify a VALIGN attribute value on
the
     cell, the default is middle although you can override this with a
     VALIGN attribute on the TR element.
width
     Specifies the suggested width for a cell content in pixels
excluding
     the cell padding. This value will normally be used except when it
     conflicts with the width requirements for other cells in the same
     column.
height
     Specifies the suggested height for a cell content in pixels
excluding
     the cell padding. This value will normally be used except when it
     conflicts with the height requirements for other cells in the same
row.

Tables are commonly rendered in bas-relief, raised up with the outer
border
as a bevel, and individual cells inset into this raised surface. Borders
around individual cells are only drawn if the cell has explicit content.
White space doesn't count for this purpose with the exception of &nbsp;.

The algorithms used to automatically size tables should take into
account
the minimum and maximum width requirements for each cell. This is used
to
determine the minimum and maximum width requirements for each column and
hence for the table itself.

Cells spanning more than one column contribute to the widths of each of
the
columns spanned. One approach is to evenly apportion the cell's minimum
and
maximum width between these columns, another is to weight the
apportioning
according to the contributions from cells that don't span multiple
columns.

For some user agents it may be necessary or desirable to break text
lines
within words. In such cases a visual indication that this has occurred
is
advised.
The minimum and maximum width of nested tables contribute to the minimum
and
maximum width of the cell in which they occur. Once the width
requirements
are known for the top level table, the column widths for that table can
be
assigned. This allows the widths of nested tables to be assigned and
hence
in turn the column widths of such tables. If practical, all columns
should
be assigned at least their minimum widths. It is suggested that any
surplus
space is then shared out proportional to the difference between the
minimum
and maximum width requirements of each column.

Note that pixel values for width and height refer to screen pixels, and
should be multiplied by an appropriate factor when rendering to very
high
resolution devices such as laser printers. For instance if a user agent
has
a display with 75 pixels per inch and is rendering to a laser printer
with
600 dots per inch, then the pixel values given in HTML attributes should
be
multiplied by a factor of 8.

---------------------------------------------------------------------
Received on Thursday, 30 January 1997 10:44:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 October 2010 18:14:22 GMT