10. HTML Table Tutorial for Beginners

First of all it is HTML table tutorial for beginners.The HTML tables permit internet authors to rearrange knowledge like text, images, links, alternative tables, etc. into rows and columns of cells.
The HTML tables ar created mistreatment the <table> tag during which the <tr> tag is employed to form table rows and <td> tag is employed to form knowledge cells.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table border="1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>

HTML table tutorial for beginners

Here, the border is associate degree attribute of <table> tag and it’s accustomed place a border across all the cells. If you are doing not would like a border, then you’ll be able to use border=”0″.

Table Heading

Table heading may be outlined mistreatment <th> tag. This tag are place to switch <td> tag, that is employed to represent actual knowledge cell. commonly you’ll place your prime row as table heading as shown below, otherwise you’ll be able to use <th> part in any row.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Header</title>
</head>
<body>
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>

HTML table tutorial for beginners

Cellpadding and Cellspacing Attributes

There ar 2 attributes referred to as cellpadding and cellspacing that you’ll use to regulate the white area in your table cells. The cellspacing attribute defines the breadth of the border, whereas cellpadding represents the space between cell borders and also the content at intervals a cell.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Cellpadding</title>
</head>
<body>
<table border="1" cellpadding="5" cellspacing="5">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
(HTML table tutorial for beginners)

HTML table tutorial for beginners

Colspan and Rowspan Attributes

You will use colspan attribute if you would like to merge 2 or additional columns into one column. Similar approach you’ll use rowspan if you would like to merge 2 or additional rows.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Colspan/Rowspan</title>
</head>
<body>
<table border="1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td><td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
</body>
</html>

HTML table tutorial for beginners

Tables Backgrounds

You can set table background mistreatment one among the subsequent 2 ways:
1.bgcolor attribute – you’ll be able to set background color for whole table or simply for one cell.
2.background attribute – you’ll be able to set background image for whole table or simply for one cell.

You can additionally set border color additionally mistreatment bordercolor attribute.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Background</title>
</head>
<body>
<table border="1" bordercolor="green" bgcolor="yellow">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td><td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
</body>
</html>

HTML table tutorial for beginners

Here is AN example of victimisation background attribute. Here we’ll use a picture accessible in /images directory.

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Background</title>
</head>
<body>
<table border="1" bordercolor="green" background="/images/test.png">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td><td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
</body>
</html>
(HTML table tutorial for beginners)

HTML table tutorial for beginners

Table Height and Width

You can set a table breadth and height mistreatment breadth and height attributes. you’ll be able to specify table breadth or height in terms of pixels or in terms of proportion of obtainable screen space.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Width/Height</title>
</head>
<body>
<table border="1" width="400" height="150">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>

HTML table tutorial for beginners

Table Caption

The caption tag can function a title or clarification for the table and it shows up at the highest of the table. This tag is deprecated in newer version of HTML/XHTML

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table Caption</title>
</head>
<body>
<table border="1" width="100%">
<caption>This is the caption</caption>
<tr>
<td>row 1, column 1</td><td>row 1, column 2</td>
</tr>
<tr>
<td>row 2, column 1</td><td>row 2, column 2</td>
</tr>
</table>
</body>
</html>

HTML table tutorial for beginners

Table Header, Body, and Footer

Tables may be divided into 3 portions: a header, a body, and a foot. the pinnacle and foot ar rather kind of like headers and footers in a very word-processed document that stay a similar for each page, whereas the body is that the main content holder of the table.
The 3 components for separating the pinnacle, body, and foot of a table are:
· <thead> – to form a separate table header.
· <tbody> – to point the most body of the table.
· <tfoot> – to form a separate table footer.

A table could contain many <tbody> components to point totally different pages or teams of knowledge. however it’s notable that <thead> and <tfoot> tags ought to seem before <tbody>

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table</title>
</head>
<body>
<table border="1" width="100%">
<thead>
<tr>
<td colspan="4">This is the head of the table</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">This is the foot of the table</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
</tbody>
</table>
</body>
</html>

HTML table tutorial for beginners

Nested Tables

You can use one table within another table. Not solely tables you’ll be able to use the majority the tags within table knowledge tag <td>.

Example

<!DOCTYPE html>
<html>
<head>
<title>HTML Table</title>
</head>
<body>
<table border="1" width="100%">
<tr>
<td>
<table border="1" width="100%">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

HTML table tutorial for beginners

It was all about HTML table tutorial for beginners.You have to practice this steps to become a good web designer.Our next article is about.Read It here XX.

 

 

Comments

comments