HTML <table> tagS2C Home   « HTML <table> tag

Definition

The <table> tag is used to define a table.

Example


<table>
  <tr>
    <th>Fruit</th>
    <th>Colour</th>
  </tr>
  <tr>
    <td>Banana</td>
    <td>Yellow</td>
  </tr>
  <tr>
    <td>Pea</td>
    <td>Green</td>
  </tr>
</table>

Required Attributes

NONE

Optional Attributes

align - this attribute is deprecated - use CSS instead.

bgcolor - this attribute is deprecated - use CSS instead.

border - specifies the width of borders around a table in pixels - use CSS instead.

cellpadding - specifies spacing between cell content and cell edge in pixels - use CSS instead.

frame - specifies visible external borders - use CSS instead.

rules - specifies visible internal borders - use CSS instead.

width - specifies the table width - use CSS instead.

summary specifies a textual summary of the content of the table.


<table summary="textualSummary"></table>

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<table class="classname"></table>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<table id="idname"></table>

style - specifies an inline style for the element allowing you to apply the style to the content.


<table style="color:red;text-align:left"></table>

title - specifies extra information about the content.


<table title="information about the content"></table>

Language Attributes

dir - specifies the directional flow of the content.


<table dir="ltr"></table>   <!-- The text will flow from left to right -->

<table dir="rtl"></table>   <!-- The text will flow from right to left -->

lang - specifies a language code for the content of the element.


<table lang="en"></table>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<table xml:lang="fr"></table>

Document Event Attributes

NONE

Form Event Attributes

NONE

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<table onkeydown="go()"></table>   <!-- Executes the go() function -->

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<table onkeypress="go()"></table>   <!-- Executes the go() function -->

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<table onkeyup="go()"></table>   <!-- Executes the go() function -->

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<table onclick="go()"></table>   <!-- Executes the go() function --> 

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<table ondblclick="go()"></table>   <!-- Executes the go() function -->

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<table onmousedown="go()"></table>   <!-- Executes the go() function -->

onmousemove - The JavaScript code to be run when the mouse button is moved.


<table onmousemove="go()"></table>   <!-- Executes the go() function -->

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<table onmouseout="go()"></table>   <!-- Executes the go() function -->

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<table onmouseover="go()"></table>   <!-- Executes the go() function -->

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<table onmouseup="go()"></table>   <!-- Executes the go() function -->

go to home page Homepage go to top of page Top