Articles → HTML → Table In HTML
Table In HTML
What Is A Table?
Syntax
<table border="">
<tr>
<td></td>
<td></td>
</tr>
</table>
- tr stands for table row (every tr represents a new row in the table)
- td stands for table data (every td represents a new column in the table)
- Here border attribute in the table tag specifies the width of the border. It could be either zero (o) or one (1)
Example
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<table border="1">
<tr>
<td>Employee</td>
<td>Location</td>
</tr>
<tr>
<td>Karan</td>
<td>Gurgaon</td>
</tr>
<tr>
<td>Ritesh</td>
<td>Delhi</td>
</tr>
</table>
</body>
</html>
Try It
Output
Cellpadding And Cellspacing In Tables
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<table border="1" cellpadding="40" cellspacing="40">
<tr>
<td>Employee</td>
<td>Location</td>
</tr>
<tr>
<td>Karan</td>
<td>Gurgaon</td>
</tr>
<tr>
<td>Ritesh</td>
<td>Delhi</td>
</tr>
</table>
</body>
</html>
Try It
Rowspan And Columnspan In HTML
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Rowspan demo</title>
</head>
<body>
<table border="1">
<tr>
<td>Employee</td>
<td>Location</td>
</tr>
<tr>
<td>Karan</td>
<td rowspan="2">Gurgaon</td>
</tr>
<tr>
<td>Ritesh</td>
</tr>
</table>
</body>
</html>
Try It
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Colspan demo</title>
</head>
<body>
<table border="1">
<tr>
<td>Location</td>
<td>Employee</td>
</tr>
<tr>
<td colspan="2">Gurgaon</td>
</tr>
<tr>
<td>Karan</td>
<td>Ritesh</td>
</tr>
</table>
</body>
</html>
Try It
Browser Support
Internet Explorer | Firefox | Chrome | Safari | Opera | Edge |
---|
Yes | Yes | Yes | Yes | Yes | Yes |