w3resource

HTML tbody tag and element

HTML tbody element

1. HTML tbody (table body) element defines body of an HTML table.

2. A table body starts with <tbody> tag. And ends with </tbody> tag, both start and end tags are optional.

Syntax

 <tbody> 
.......
</tbody>

Category

HTML tbody element is a part of HTML Tables.

Whether both start and end tags are required

Start and end, both tags are optional.

Can contain

HTML tbody element can contain One or more tr elements.

Can reside within

HTML tfoot element can reside within a table element.

Attributes

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

Cell alignment

align, char and charoff attributes.

Supported doctypes

HTML 4.01 Strict, HTML 4.01 Transitional, and HTML 4.01 Frameset.

Example of using HTML tbody element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>html tbody tag example</title>
</head>
<body>
<table border="1">
<thead>
<tr> 
<th>Student code </th>
<th>% of marks </th>
</tr>
</thead>
<tbody>
<tr> 
<td>S001</td>
<td>85</td>
</tr>
<tr> 
<td>S002</td>
<td>86</td>
</tr>
<tr> 
<td>S003</td>
<td>72</td>
</tr>
<tr> 
<td>S004</td>
<td>89</td>
</tr>
</tbody>
</table>
</body>
</html>

Result

html tbody element

View this example in a separate browser window

HTML tbody tag example.

Pictorial presentation

html tbody tag

Previous: HTML tfoot tag and element
Next: HTML colgroup element

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.