BBC Home

Explore the BBC

h2g2
26th December 2009
Accessibility help
Text only

Guide ID: A957495 (Help Page)

Help Page


SEARCH h2g2
Edited Entries only
Search h2g2Advanced Search


New visitors: Create your membership
Returning members: Sign in
BBC Homepage
The Guide to Life, The Universe and Everything.


Created: 5th February 2003
GuideML - TABLE Tag
Contact Us


Like this page?
Send it to a friend!

 

Tables are used to lay out content in tabular format. The <TABLE> tag is the main construct, but the complete list of tags covered here comprises:

  • <TABLE>
  • <TD>
  • <TH>
  • <TR>
  • <CAPTION>

Syntax and Usage

Optional attributes are shown in italics, and the vertical bar character | denotes a choice, so LEFT|CENTER|RIGHT means one of LEFT, CENTER or RIGHT.

<TABLE BORDER="1">

<CAPTION>Caption</CAPTION>

<TR ALIGN="LEFT|CENTER|RIGHT" VALIGN="TOP|MIDDLE|BOTTOM">

<TD|TH ALIGN="LEFT|CENTER|RIGHT" VALIGN="TOP|MIDDLE|BOTTOM" COLSPAN="n" ROWSPAN="n">...cell contents...</TD|TH>

...more cells...

</TR>

...more rows...

</TABLE>

Here's how to create a table:

  • Start a table with a <TABLE> tag, and end it with a corresponding </TABLE> tag; these act like a paragraph tag pair, so don't put a table inside a paragraph, blockquote and so on.

  • Rows are created one after the other, with each row enclosed by a <TR>...</TR> pair. For each row we have to create each cell in that row, from left to right, with the contents of each cell being enclosed by a <TD>...</TD> pair (or <TH>...</TH> for a header cell, which is just like a normal row but is displayed as a header row, usually in bold).

  • If you want a cell to be blank, use &nbsp; as the cell's contents. &nbsp; is the entity for a non-breaking space, and should be used for empty cells: never create an empty cell with <TD></TD> as this might cause some problems with some browsers (notably Netscape).

  • Putting BORDER="1" after the TABLE tag will put a border round each table cell. This is useful if you think you're going to have multiple-line cells and things might not line up obviously.

  • The ALIGN and VALIGN attributes control how the text is aligned horizontally and vertically within cells. If included with the <TR> tag they control that whole row, whereas putting them with individual cells controls just those cells' alignments.

  • The COLSPAN and ROWSPAN attributes make cells span multiple columns and rows, the number being given by the argument. The best way to discover how these work is by experimentation.

Known Issues

Both Netscape and Internet Explorer reset the font in table cells to the default for that page, and ignore the current settings. This means that the font inside table cells will probably revert to Times. Changing fonts, however, is not possible in Approved GuideML, so this problem will be fixed at the parser end.

Example One

 RainfallSunlight
Britain30mZero
Everywhere Else0m12 hrs

Example Two

The caption goes here
A Table of Meaningless Words
Multiple
Line
TopMiddleBottom
To the rightCentre

Further Information



Clip/Bookmark this page
This article has not been bookmarked.
ENTRY DATA
Edited by:

The h2g2 Editors

Referenced Sites:

Using <TABLE> in the h2g2...

Please note that the BBC is not responsible for the content of any external sites listed.


CONVERSATION TOPICS FOR THIS ENTRY:

Start a new conversation

People have been talking about this Guide Entry. Here are the most recent Conversations:

TITLE
LATEST POST
Above and beyondApr 28, 2007
Incomplete ?Aug 15, 2006




Disclaimer

Most of the content on h2g2 is created by h2g2's Researchers, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the BBC. The BBC is not responsible for the content of any external sites referenced. In the event that you consider anything on this page to be in breach of the site's House Rules, please click here. For any other comments, please start a Conversation above.




About the BBC | Help | Terms of Use | Privacy & Cookies Policy