HTML creating tables Free Web Design Tutorials
Home   HTML CSS JavaScript PHP MySQL Usability Glossary
HTMLBasicsCreating a DocumentHead and Body ElementsFormatting TextCreating ListsEmbedding ImagesURLs ExplainedLinking to DocumentsHTML Creating TablesCreating TablesForms - BasicsInput and TextareaSelect ListsFramesetsThe Frame ElementNested FramesetsTargeting FramesInline Frames

Home > HTML > Creating Tablesprinter version

HTML - Creating Tables

HTML provides tables for structuring numerical or other information in an accessible way - such as with a bus timetable. However, many designers use tables to format chunks of content into columns and rows.

This is frowned upon by some designers who say that the <div> element (covered in CSS) should be used for this and that tables should only be used for their intended purpose.

The Basic Structure of a Table
<table>
    <tr>
        <th>
            Heading in here
        </th>
        <td>
            Content in here
        </td>
    </tr>
</table>


A table has only one <table> element, which must have a closing tag, but there may be multiple <tr>, <th> and <td> elements, each of which must have closing tags.

The <tr> elements enclose the <th> and <td> elements and provide the rows of the table.

The <th> elements enclose the cell headings and the <td> elements enclose the content and provide the columns of the table.

The <th> element is optional and may be omitted if a heading above each cell is not required.

By default headings within <th> elements are displayed in bold text and centred whereas within <td> elements, content is displayed in normal text and left aligned.

If multiple rows and multiple columns are employed then the number of columns in each row must match i.e. each <tr> element must enclose the same number of <th> or <td> elements.

<table> Attributes

The <table> element supports a number of attributes, some of which are listed below.

A Table tag with attributes
<table align="center" bgcolor="#ff0000" border="2" cellpadding="4" cellspacing="8" width="50%">


<tr> Attributes

The <tr> element supports a number of attributes, some of which are listed below.

<th> and <td> Attributes

The <td> element supports a number of attributes, some of which are listed below.

Previous - HTML linking to other documents Previous - Linking to Other Documents     Next - Forms - Basics Next - HTML forms - basics


Privacy | Terms | Contact | Links | Sitemap | RSS Feeds RSS and JavaScript Feeds
©2009 www.webdesignworkmate.co.uk all rights reserved 
Design and Production by smallbizonline website design © 2000-2009
Valid HTML 4.01! Level Double-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0Valid CSS!
Recommended Reading
html_and_xhtml

html and xhtml complete reference

learning web design beginners guide