Beginning HTML5 and CSS3 For Dummies
Book image
Explore Book Buy On Amazon

Tables let you organize information on your Web page and give it an organized look that your visitors will find useful. When used as intended, tables have rows and columns. For each spot where a row and column intersect, you have a table cell. Each cell can have its own formatting: the data in it can be aligned left, center, or right, formatted, and so on. Tables also have header-data cells, in which you put the column headings. You can create a table in Notepad. Here’s the HTML code for a simple table of this type:

Production (tons)% of goal
>North 4087102%
South 4093110%

This is how this simple table looks in HTML and when viewed in Internet Explorer.

A simple Web table and its simple HTML source.
A simple Web table and its simple HTML source.

Here’s what each part of the HTML code does:

  • : The TABLE tag begins and ends the table. The BORDER attribute creates a 2-pixel-wide border around the table. Don’t forget to include a border, so other text and graphics in your Web page don’t crowd too close to the table.

  • , : These tags begin and end the table row.

  • : These tags surround table header data. Table header data is automatically formatted as bold and centered.

  • : These tags begin and end the table data item.

    So creating a table in HTML is fairly simple but also fairly tedious. You just create the rows and data items; if you get the data items right, the columns take care of themselves.

    Getting the data items right can be a problem, though. To make your table look just right, you have to use alignment and formatting options. Making mistakes becomes way too easy, and updating the table’s appearance becomes very hard. That’s why so many people use an HTML editor like CoffeeCup to create and manage tables and then, in some cases, do final tweaking in HTML to get them just right.

    , ,

About This Article

This article is from the book:

About the book authors:

Ed Tittel is a 30-year veteran of the technology industry, with more than 140 computing books to his credit, including the bestselling HTML For Dummies. Chris Minnick is an author, trainer, and web developer who has worked on web and mobile projects for both small and major businesses. Learn more at watzthis.com.

This article can be found in the category: