Tables in HTML
Tables in HTML
Definition: The HTML tables are used to arrange data into rows and columns. HTML tables are
created using the <table> tag. The <tr> tag is used to create table rows and <td> tag is used to
create cells in row. The elements under <td> are regular and left aligned by default
Table Heading
The <th> tag is used for table heading. It is used in <tr> tag in place of <td> tag. Headings,
which are defined in <th> tag are centered and bold by default.
3. Cellpadding
Cellpadding is used to specify the space between the cell value and cell border. It
sets space in terms of pixels.
4. Align
The align attribute is used to specify the alignment of the table and its content. By
default alignment is left. It has following syntax.
5. Valign
It is used to define the vertical alignment of the content of a table cell. It has following
syntax.
6. Nowrap
Nowrap attributes prevents text in a cell from wrapping. All text in a cell appears on
one line. It can be with <td> and <th> tags. It has following syntax.
<td nowrap>text</td>
7. Colspan
It is used to span a cell over multiple columns. It can be with <td> and <th> tags. It
has following syntax.
8. Rowspan
It is used to span a cell over multiple rows. It can be with <td> and <th> tags. It has
following syntax.
<html>
<body>
<table border="1" cellspacing="20" cellpadding="10"
align="left">
<tr>
<th colspan="3">Student data</th>
</tr>
<tr>
<th>Roll No</th>
<th>Name</th>
<th>Marks</th>
</tr>
<tr>
<td nowrap>1</td>
<td valign="center">Ali</td>
<td valign="bottom">98</td>
</tr>
</table>
</body>
</html>