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> element.

The <tr> tag can contain one or more <th> or one or more <td> elements.

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>
Fruit Colour
Banana Yellow
Pea Green

Attributes

The following attributes can be used with the <tr> tag.


<tr> Specific Attributes
Attribute Value Description Example
There are no required or optional attributes specific to the <tr> tag.
<tr> Global Attributes
Attribute Description Example
Common
classSpecifies a classname for the element allowing you to apply the style of the predefined class to the content.

<tr class="name">Table row content</tr>
idSpecifies a unique id for the element allowing you to apply the style of the predefined id to the content.

<tr id="name">Table row content</tr>
styleSpecifies an inline style for the element allowing you to apply the style to the contentt.

<tr style="color:red;">Table row content</tr>
titleSpecifies an inline style for the element allowing you to apply the style to the content.

<tr title="Content info">Table row content</tr>
Keyboard
accesskeySpecifies a keyboard shortcut to associate with the element.

<tr accesskey="a">Table row content</tr>
tabindexSpecifies a tab order for the element.

<tr tabindex="1">Table row content</tr>
Language
dirSpecifies the directional flow of the content.

<!-- The text will flow from left to right -->
<tr dir="ltr">Table row content</tr>
<!-- The text will flow from right to left -->
<tr dir="rtl">Table row content</tr>
langSpecifies a language code for the content of the element.

<tr lang="en">Table row content</tr>
spellcheckSpecifies an inline style for the element allowing you to apply the style to the contentt.

<!-- Valid values true and false. -->
<!-- Default inherited / browser specific. -->
<tr spellcheck="true">Table row content</tr> 
translateSpecifies an inline style for the element allowing you to apply the style to the content.

<!-- Valid values yes and no. -->
<!-- Default yes. -->
<tr translate="no">Table row content</tr> 
Miscellaneous
contenteditableSpecifies whether the content of the element is editable.

<!-- Valid values true and false. -->
<!-- Default inherited. -->
<tr contenteditable="true">Table row content</tr> 
draggableSpecifies whether the element is draggable.

<!-- Valid values true and false. -->
<!-- Default browser specific. -->
<tr draggable="true">Table row content</tr>
hiddenSpecifies whether the element is not yet, or no longer, relevant.

<!-- Valid values an empty string or hidden -->
<tr hidden>Table row content</tr> 
<tr hidden="hidden">Table row content</tr> 
<tr> Event Attributes
Attribute Description Example
Document Element
oncopyThe script to be run when the user copies the content of an element.

 <!-- Executes go() function -->
<tr oncopy="go()">Table row content</tr> 
oncutThe script to be run when the user cuts the content of an element.

 <!-- Executes go() function -->
<tr oncut="go()">Table row content</tr>
onpasteThe script to be run when the user pastes some content into an element.

 <!-- Executes go() function -->
<tr onpaste="go()">Table row content</tr>
Drag and Drop
ondragThe script to be run when an element is dragged.

 <!-- Executes go() function -->
<tr ondrag="go()">Table row content</tr>
ondragendThe script to be run when an element has stopped being dragged.

 <!-- Executes go() function -->
<tr ondragend="go()">Table row content</tr>
ondragenterThe script to be run when an element has been dragged to a valid drop target.

 <!-- Executes go() function -->
<tr ondragenter="go()">Table row content</tr>
ondragleaveThe script to be run when an element leaves a valid drop target.

 <!-- Executes go() function -->
<tr ondragleave="go()">Table row content</tr>
ondragoverThe script to be run when an element is being dragged over a valid drop target.

 <!-- Executes go() function -->
<tr ondragover="go()">Table row content</tr>
ondragstartThe script to be run at the start of a drag operation.

 <!-- Executes go() function -->
<tr ondragstart="go()">Table row content</tr>
ondropThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<tr ondrop="go()">Table row content</tr>
Form
onblurThe script to be run when the element loses focus.

 <!-- Executes go() function -->
<tr onblur="go()">Table row content</tr>
onchangeThe script to be run when object changed and attempt to leave field.

 <!-- Executes go() function -->
<tr onchange="go()">Table row content</tr>
oncontextmenuThe script to be run when a context menu is triggered.

 <!-- Executes go() function -->
<tr oncontextmenu="go()">Table row content</tr>
onfocusThe script to be run when the element gets focus.

 <!-- Executes go() function -->
<tr onfocus="go()">Table row content</tr>
oninputThe script to be run when an element gets user input.

 <!-- Executes go() function -->
<tr oninput="go()">Table row content</tr>
oninvalidThe script to be run when an element is invalid.

 <!-- Executes go() function -->
<tr oninvalid="go()">Table row content</tr>
onresetThe script to be run when a dragged element is being dropped.

 <!-- Executes go() function -->
<tr onreset="go()">Table row content</tr>
onselectThe script to be run when some or all of the contents of an object are selected.

 <!-- Executes go() function -->
<tr onselect="go()">Table row content</tr>
onsubmitThe script to be run when a form is submitted.

 <!-- Executes go() function -->
<tr onsubmit="go()">Table row content</tr>
Keyboard
onkeydownThe script to be run when an element is in focus and keyboard key is pressed down.

 <!-- Executes go() function -->
<tr onkeydown="go()">Table row content</tr>
onkeypressThe script to be run when an element is in focus and keyboard key is pressed down and released.

 <!-- Executes go() function -->
<tr onkeypress="go()">Table row content</tr>
onkeyupThe script to be run when an element is in focus and keyboard key is released.

 <!-- Executes go() function -->
<tr onkeyup="go()">Table row content</tr>
Media
onabortThe script code to be run on abort.

 <!-- Executes go() function -->
<tr onabort="go()">Table row content</tr>
oncanplayThe script to be run when a file has buffered enough so it is ready to start playing.

 <!-- Executes go() function -->
<tr oncanplay="go()">Table row content</tr>
oncanplaythroughThe script to be run when a file can be played all the way to the end without further need of buffering.

 <!-- Executes go() function -->
<tr oncanplaythrough="go()">Table row content</tr>
oncuechangeThe script to be run when the cue changes when using the track element.

 <!-- Executes go() function -->
<tr oncuechange="go()">Table row content</tr>
ondurationchangeThe script to be run when the length of the media is changed.

 <!-- Executes go() function -->
<tr ondurationchange="go()">Table row content</tr>
onemptiedThe script to be run when a media resource element suddenly becomes empty, usually due to an error.

 <!-- Executes go() function -->
<tr onemptied="go()">Table row content</tr>
onendedThe script to be run when the media has reach the end.

 <!-- Executes go() function -->
<tr onended="go()">Table row content</tr>
onloadeddataThe script to be run when media data is loaded and playback can start.

 <!-- Executes go() function -->
<tr onloadeddata="go()">Table row content</tr>
onloadedmetadataThe script to be run when metadata has been loaded.

 <!-- Executes go() function -->
<tr onloadedmetadata="go()">Table row content</tr>
onloadstartThe script to be run whenthe media resource has started loading.

 <!-- Executes go() function -->
<tr onloadstart="go()">Table row content</tr>
onpauseThe script to be run when the media resource has been paused.

 <!-- Executes go() function -->
<tr onpause="go()">Table row content</tr>
onplayThe script to be run when the media resource starts playback.

 <!-- Executes go() function -->
<tr onplay="go()">Table row content</tr>
onplayingThe script to be run when when playback has already begun.

 <!-- Executes go() function -->
<tr onplaying="go()">Table row content</tr>
onprogressThe script to be run when the browser is fetching the media data.

 <!-- Executes go() function -->
<tr onprogress="go()">Table row content</tr>
onratechangeThe script to be run when the playback rate changes.

 <!-- Executes go() function -->
<tr onratechange="go()">Table row content</tr>
onseekedThe script to be run when the seeking attribute is set to false indicating that seeking has finished.

 <!-- Executes go() function -->
<tr onseeked="go()">Table row content</tr>
onseekingThe script to be run when the seeking attribute is set to true indicating that seeking is currently active.

 <!-- Executes go() function -->
<tr onseeking="go()">Table row content</tr>
onstalledThe script to be run when the browser is unable to continue fetching media data.

 <!-- Executes go() function -->
<tr onstalled="go()">Table row content</tr>
onsuspendThe script to be run when media data has stopped before being completely loaded.

 <!-- Executes go() function -->
<tr onsuspend="go()">Table row content</tr>
ontimeupdateThe script to be run when the media resources current playback position has changed.

 <!-- Executes go() function -->
<tr ontimeupdate="go()">Table row content</tr>
onvolumechangeThe script to be run when the volume has changed or been muted.

 <!-- Executes go() function -->
<tr onvolumechange="go()">Table row content</tr>
onwaitingThe script to be run when the media resource has paused but is expected to resume.

 <!-- Executes go() function -->
<tr onwaiting="go()">Table row content</tr>
Mouse
onclickThe script to be run when when a mouse is clicked on an element.

 <!-- Executes go() function -->
<tr onclick="go()">Table row content</tr>
ondblclickThe script to be run when a mouse is double clicked on an element.

 <!-- Executes go() function -->
<tr ondblclick="go()">Table row content</tr>
onmousedownThe script to be run when he mouse button is pressed down while the cursor is over an element.

 <!-- Executes go() function -->
<tr onmousedown="go()">Table row content</tr>
onmousemoveThe script to be run when the mouse button is moved.

 <!-- Executes go() function -->
<tr onmousemove="go()">Table row content</tr>
onmouseoutThe script to be run when the mouse cursor moves off an element.

 <!-- Executes go() function -->
<tr onmouseout="go()">Table row content</tr>
onmouseoverThe script to be run when the mouse cursor moves over an element.

 <!-- Executes go() function -->
<tr onmouseover="go()">Table row content</tr>
onmouseupThe script to be run when the mouse button is released while the cursor is over the element.

 <!-- Executes go() function -->
<tr onmouseup="go()">Table row content</tr>
onwheelThe script to be run when the mouse wheel rolls up or down over an element.

 <!-- Executes go() function -->
<tr onwheel="go()">Table row content</tr>
Scroll
onscrollThe script code to be run when the scrollbar of an element is being scrolled.

 <!-- Executes go() function -->
<tr onscroll="go()">Table row content</tr> 
Window - NONE