Copyright © tutorialspoint.com

HTML <table> tag



Advertisements

Function:

The HTML &ld;table> tag is used for defining a table. The table tag contains other tags that define the structure of the table.

Difference between HTML and XHTML:

The align and bgcolor attributes are deprecated in HTML as well in XHTML.

Example:

<table width="100%" border = "1">
<tr>
<th>Tag</th>
<th>Description</th>
</tr>
<tr>
<td>th</td>
<td>Specifies a table header</td>
</tr>
</table>

This will produce following result:

Tag Description
th Specifies a table header

Online Practice:

To Become more comfortable - Do Online Practice

Attributes:

AttributeValueDescription
abbrabbreviated_textSpecifies an abbreviated version of the content in a cell.
alignright
left
center
justify
char
Deprecated - Visual alignment.
bgcolorrgb(x,x,x)
#hexcode
colorname
Deprecated - Specifies the background color of the table.
borderpixelsSpecifies the border width. A value of "0" means no border.
cellpaddingpixels or %Specifies the space between the cell borders and their contents.
cellspacingpixels or %Specifies the space between cells.
framevoid
above
below
hsides
lhs
rhs
vsides
box
border
Used in conjunction with the border attribute, specifies which side of the frame that makes up the border surrounding the table is displayed.
rulenone
groups
rows
cols
all
Used in conjunction with the border attribute, specifies which rules appear between the cells of the table.
widthpixels or %Specifies the width of the table

Standard Attributes:

AttributeDescription
classDocument wide identifier
dirSpecifies the direction of the text
idDocument wide identifier
titleSpecifies a title to associate with the element.
styleHelps to include inline casecadubf style sheet.
langSets the language code.
xml:langSets the language code.

Event Attributes:

AttributeDescription
onclickScript runs when a mouse click
ondblclickScript runs when a mouse double-click
onmousedownScript runs when mouse button is pressed
onmouseupScript runs when mouse button is released
onmouseoverScript runs when mouse pointer moves over an element
onmousemoveScript runs when mouse pointer moves
onmouseoutScript runs when mouse pointer moves out of an element
onkeypressScript runs when key is pressed and released
onkeydownScript runs when key is pressed
onkeyupScript runs when key is released

Copyright © tutorialspoint.com