301: Adding a Table to your Website

Written By: Tim Sisson
Experience Level: Intermediate
Articles labeled as Intermediate are those that require tasks to be completed that often require you have an understanding / skill of a more advanced topic beforehand. Intermediate articles may also be tasks that require more than just 2 - 3 minutes of your time, such as setting up an online store. Our Technical Support Department may be able to directly assist, however it is on a case by case basis.
Print E-mail:

A great way to organize your content on your website is to use tables. If you have ever used a word processing program like MS Word or Open Office, tables offer the same style. Before completing this section make sure you have completed the course on Web Design Basics.

To add a table to your website, the basic HTML code will look like this:

<table>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

which would display on your webspage like this:

row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2

Creating a table with HTML?

So let's get a better understanding of the code, first we have the tags to start and close the table:

<table>
</table>

Now we will add the first row.  A row is shown with a <tr> tag:

<table>
<tr>

Next, the cells will be added.  A cell is shown with a <td> tag:

<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>

Finally we will close that row, and then start the next row:

<table>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>

You can repeat this to have as many rows and columns as you need.

Adding a border to your HTML table

In the example above we created a table with no borders, but you can create a table with borders as well.  Using the above example:

<table>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

All that needs to be added is in the first tag, the border attribute can be specified as border="1":

<table border ="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

Which would display:

row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2

There are other attributes you can add to a table as well such as cellspacing and cellpadding to increase the space between the cells and around the table, however this is meant to be an introduction to tables.

 
Rating:
 
Please log in to rate this article.
Like this Article?
Notify Me of Updates!
Please login to subscribe to receive notifications when this article is updated.
Prerequisite Articles
None

Comments

Currently no comments

You must log in before commenting.

Need more Help?

Search
Current Customers
Chat:Click to Chat Now
Call:888-321-HOST (4678)
E-mail:support@InMotionHosting.com
Ticket Submit a Support Ticket
Ask the Community!
Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.
Not a Customer?
Get web hosting from a company that is here to help. Sign up today!

Follow InMotion Hosting!

 4236 Followers. Follow Us!

Continuing Education

Follow this Education Channel to stay up to date on Website Design! (what is this?)
If you're familiar with the traditional setup of college courses, then learning through our Education Channels will be a breeze. We begin with an introductory 101 class, and advance all the way up to 300 level classes. Stay up to date on your favorite topics by becoming a fan on facebook and following us on twitter (links in the right sidebar of the page).
  Followers. Follow Us!

Further Your Education!

Subscribe To Other Education Channels!

Everything Email
Website Design
Premium Website Builder
cPanel
WordPress
Using Web Host Manager
OpenCart
Magento Tutorial

Have a Question?

If you need some help, submit your question to our Community!
We guarantee a response within 60 minutes (8am - 5pm EST, Monday - Friday)

Recent Questions