HTML <table> tag

Updated: 10/11/2017 by Computer Hope

HTML table tagWhen writing in HTML, the <table> tag is a block element used to create a table. It is useful when you want to represent data using rows and columns. The basic elements that make up a table include <th>, <td>, and <tr>. The following sections contain information about the <table> tag, including an example of it in use, as well as related attributes and browser compatibility.

Tip: More advanced tables may also include the <caption>, <col>, <colgroup>, <tbody>, <tfoot>, or <thead> elements.

Example code

<table class="mtable2 tab">
<tr class="tcw">
<tr class="tcw">
<tr class="tcw"> <td>May</td>

Example result

Month Savings
March $200
April $300
May $250

We have added a few of our own classes to the table using CSS; this action allows us to improve its appearance.

Deprecated attributes

Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. Every attribute that was unique to the <table> tag has been deprecated. While these attributes may work with the some versions of HTML, they will eventually be phased out. You should use CSS to adjust the dimensions and appearance of this element.

Attribute Description
align Designates the alignment of content inside an element
bgcolor Designates the background color of a table
border Designates whether or not cell should have a border
cellpadding Designates how much spacing is between the cell wall and the cell content
cellspacing Designates spacing between cells
frame Designates which parts of the outside borders are visible
rules Designates  which parts of the inside borders are visible
sortable Designates that a table is sortable
summary Designates what the contents of the table are
width Designates how wide the table should be


Internet Explorer Firefox Safari Opera Chrome
4.0+ All versions All version 7.0+ All versions

Related pages

Browser, Cell, Class, Column, Compatibility, Format, Row, Table, Web design terms