Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML tag

HTML tag

Example

A simple HTML table with two cells:

Cell A Cell B

Try it »

(More examples are at the bottom of the page)


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the tag.


Tag Definition and Usage Notes

The tag defines a standard cell in an HTML table.

HTML tables have two types of cells:

Text in the element is usually rendered bold and centered. Text in the element is usually normal, left-aligned text.

Tips and Notes

**Tip:** If you need to span content across multiple rows or columns, use the colspan and rowspan attributes!


Differences between HTML 4.01 and HTML5

Some attributes from HTML 4.01 are no longer supported in HTML 5.


property

property Value Description
abbr text Not supported in HTML5. Specifies an abbreviated version of the content in the cell.
align left
 right       

 center       

 justify       

 char | HTML5 does not support。Specifies单元格内容的水平对齐方式。 |

| axis | category_name | Not supported in HTML5. Classifies the cell. | | bgcolor | rgb(x,x,x)
#xxxxxx
colorname
| Not supported in HTML5. Deprecated in HTML 4.01. Specifies the background color of the cell. | | char | character | Not supported in HTML5. Specifies the character based on which the content is aligned. | | charoff | number | Not supported in HTML5. Specifies the offset of the alignment character. | | colspan | number | Specifies the number of columns a cell can span. | | headers | header_id | Specifies one or more header cells associated with the cell. | | height | pixels
%
| Not supported in HTML5. Deprecated in HTML 4.01.
Sets the height of the cell. | | nowrap | nowrap | Not supported in HTML5. Deprecated in HTML 4.01.
Specifies whether the content in a cell should be wrapped. | | rowspan | number | Sets the number of rows a cell should span. | | scope | col
colgroup
row
rowgroup | Not supported in HTML5. Defines a way to associate header cells with data cells. | | valign | top
middle
bottom
baseline | Not supported in HTML5. Specifies the vertical alignment of the content in a cell. | | width | pixels
%
| Not supported in HTML5. Deprecated in HTML 4.01. Specifies the width of a cell. |


Global Attributes

The tag supports [HTML Global Attributes](/tags/ref-standardattributes.html).

Event attribute

The tag supports [HTML Event Attributes](/tags/ref-eventattributes.html).

Try it - Example

Caption in a table
This example demonstrates how to display a table caption.

Empty cells
This example demonstrates how to use " " to handle cells with no content.

A table with a caption
This example demonstrates a table with a caption.

Tags inside a table
This example demonstrates how to display elements inside other elements.

Table cells spanning rows or columns
This example demonstrates how to define table cells that span rows or columns.


Related Articles

HTML Tutorial:HTML Tables

HTML DOM Reference Manual: Td Object