HTML <tr> tagS2C Home   « HTML <tr> tag

Definition

The <tr> tag is used to define a row within a table and must be enclosed within the <table></table> element.

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

bgcolor this attribute is deprecated - use CSS instead.

char no browser support - specifies character to align cells to.

charoff no browser support - specifies offset of char character in pixels.

align specifies the horizontal alignment of cell contents.


<tr align="left"></tr>   <!-- align content to the left -->
<tr align="center"></tr>   <!-- align content in the centre -->
<tr align="right"></tr>   <!-- align content to the right -->
<tr align="justify"></tr>   <!-- stretch contents to width -->
<tr align="char"></tr>   <!-- align content to a character -->

valign specifies the vertical alignment of cell contents.


<tr valign="top"></tr>   <!-- align content to the top -->
<tr valign="middle"></tr>   <!-- align content in the middle -->
<tr valign="bottom"></tr>   <!-- align content to the bottom -->
<tr valign="baseline"></tr>   <!-- align to bottom when using different font sizes -->

Common Attributes

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


<tr class="classname"></tr>

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


<tr id="idname"></tr>

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


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

title - specifies extra information about the content.


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

Language Attributes

dir - specifies the directional flow of the content.


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

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

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


<tr lang="en"></tr>

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


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

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.


<tr onkeydown="go()"></tr>   <!-- 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.


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

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


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

Mouse Event Attributes

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


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

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


<tr ondblclick="go()"></tr>   <!-- 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.


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

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


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

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


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

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


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

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


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

go to home page Homepage go to top of page Top