Create a Basic Table with table tr td elements
Description
There are three elements that every table must contain:
table
, tr
, and td
.
table
table
with local sttributes border
marks a table in an HTML document.
table
element can have
caption, colgroup, thead, tbody, tfoot, tr, th, and td
elements.
The summary, align, width, bgcolor, cellpadding, cellspacing, frame, and rules
attributes for table
element are obsolete.
The value of the border
attribute must be 1.
The thickness of the border must then be set using CSS.
tr
tr
element denotes a table row.
HTML tables are row oriented and you must denote each row separately.
tr
element can be used inside table
, thead
,
tfoot
, and tbody
elements.
tr
element can contains one or more td
or th
elements.
The align, char, charoff, valign
, and bgcolor
attributes are obsolete.
You must use CSS instead.
td
td
with colspan, rowspan, headers
local attributes
denotes a table cell.
The scope
attribute is obsolete.
Use the scope
attribute on the th
element instead.
The abbr, axis, align, width, char, charoff, valign, bgcolor, height
,
and nowrap
attributes are obsolete, and you must use CSS instead.
Example
You can combine them to create tables, as shown in the following code.
<!DOCTYPE HTML>
<html>
<body>
<table>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr><!-- www. ja va2 s .c o m-->
<tr>
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</table>
</body>
</html>
Adding Some Longer Cell Content
<!DOCTYPE HTML>
<html>
<body>
<table>
<tr>
<td>A</td>
<td>G</td>
<td>M</td>
</tr><!--from w w w. j a v a2 s .co m-->
<tr>
<td>O</td>
<td>O</td>
<td>L</td>
</tr>
<tr>
<td>E</td>
<td>Long cell</td>
<td>V</td>
</tr>
</table>
</body>
</html>