Designer Today - Graphic Design Magazine
Designer Today is the premiere graphic design magazine and tutorial resource for designers

Web Design Tutorials


 


Simple HTML Tables - Web Design Tutorial
Vikki Olds

March 15, 2004

 

Creating HTML tables by hand is not so hard once you get the hang of it. There really isn't a lot to remember. There are HTML table tag pairs that you use to create tables and the most used are:
  • <table></table>
  • <tr></tr>
  • <td></td>

There are more tag pairs that can be used also:

  • <tbody></tbody>
  • <tfoot></tfoot>
  • <th></th>
  • <thead></thead>

Each tag pair has attributes that can be assigned to them. For instance the main table definition tag can specify a background color or image, a border and border color, cellspacing/how much space is between table cells, cellpadding/how much space is between content of the cell and the cell border, width, height and more. Most people generally won't go much further than what I've mentioned and some won't even go that far.

For a very basic table you could use just the top three mentioned tag pairs:

  • <table>

    • <tr>

      • <td>

        • Content of the cell

      • </td>

    • </tr>

  • </table>

<table> and </table> are the opening and closing tags for the table. <table> is always the first item used to define a table and </table> is always the last item of a table definition.

<tr> means table row so every time you want a row you would start it with <tr> and end it with </tr>

<td> means table data so every time you want a cell for data/content you would start it with <td> and end it with </td>.

It can get confusing at times if you don't indent your code. I generally use Notepad for coding and use indents to keep my code readable as shown above. In the code above there is one row and one column which would be rendered as:

Content of the cell

With just the first few tag pairs you can get a pretty complex table happening:

     
Content of the cell

Hrmm, look what happens to the left cell when content is placed in another cell next to it. This happens because cell widths are not set. To rectify the problem all we need to do is set cell widths:

     
Content of the cell
  • <table border="1" width="50%" cellspacing="0" cellpadding="0" id="table3">

    • <tr>

      • <td rowspan="2" width="100">&nbsp;</td>

      • <td>&nbsp;</td>

      • <td>&nbsp;</td>

    • </tr>

    • <tr>

      • <td height="24" colspan="2">Content of the cell</td>

    • </tr>

  • </table>

You will notice in the code above there are two parameters that have not been mentioned so far. One of those is rowspan and the other is colspan. Tables are like a grid and each row of the grid much match up or have the rowspan or colspan parameters set to make up the difference. In the above code we have a row that really spans two rows and so we need to use rowspan="2" in the table data for that cell. We also have a column that spans two columns. Again adding the colspan parameter for that table data cell; colspan="2" fixes any problems we might encounter.

With the information above you should be able to get started creating HTML tables for your web site.

Have fun!

 

Copyright 2004, Vikki Olds, All Rights Reserved



Be the first to bookmark or share this

 

 

 



Web Design Tutorial Section

In this section you will find excellent web design tutorials and training, as well as web design tips, tricks, techniques and effects. Our writers work hard to provide free web design training for you! Our tutorials cover several different html editors and many styles and types of web design and programming. Visit the Designer Today resource directory for more web design and web graphics tutorial resources. You can also find more Web Design Tutorials at Tutorials Today.




Designer Today Tutorial CD

Designer Community Forum

Advertise on Designer Today

Search and register domains at 123 Domain Names UK, Domain Name Registration UK
and the
UK Domain Name Registration Centre

Designer Today - The Graphic Design Magazine for 2D and 3D graphic designers Hundreds of graphic design
and graphic design software tutorials, product reviews and design articles for the graphic designer


Graphic Design Articles | Graphic Design Newsletter | Graphic Design Training  
Photoshop Tutorials | Illustrator Tutorials | After Effects Tutorials


Also be sure to visit
Fun Meme Jokes and Humor | Favorite {fvrit} Blog |
Poser World | The Poser Gazette
Favorite Media |
Stock 3D wiki | Statesboro Magazine | Five Million Dots | Small Business Consumer
GMP Savings Store

Privacy Policy | Website Copyright and Terms & Agreement | Contact | Information | Site Map | Advertise | Submissions

DesignerToday.com runs on a Content Management System by GMP Services
Copyright © 1998-2008, GMP Services, Inc. -
Media Publishers of Statesboro Georgia, All Rights Reserved