HTML - Nested Tables(1)
HTML - Nested Tables(1)
Anzeige
Best Liposuctions Surgeons in Turkey (See List)
Explore popular tummy tuck treatments and their
benefits.
Tummy Tuck LEARN MORE
Nested Tables are tables that are located within other table cells. In HTML, the Nested tables involve the
utilization of one table within another, providing a versatile way to structure complex data layouts. Various
elements, including other HTML tags, can be incorporated within table cells (<td>).
Not only can tables be nested, but various HTML tags can also be used within the <td> (table data) tag for
arranging contents structured manner.
Step 1 - Create Outer Table: Begin by creating the outer table, which serves as the container.
<table border="1">
<!-- Outer table content -->
</table>
Step 2 - Define Rows and Columns: Within the outer table, define the necessary rows and columns.
<tr>
<td>
<!-- Content within the cell -->
</td>
</tr>
Step 3 - Embed Inner Table: Inside the cell, embed a new table structure using the <table> tags.
<td>
<table border="1">
<!-- Inner table content -->
</table> Safe and Effective Fat Removal Procedures…
<tr>
<td>Inner Content</td>
</tr>
</table>
Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified
expert to boost your career.
A new table can be defined inside a cell of another table, this is called nested table. The below HTML
program creates a table with two columns (Employees and NetWorth). Inside the first column, there's a
nested table displaying employee details.
Open Compiler
Safe and Effective Fat Removal Procedures…
<body>
<table border="1">
<tr>
<th>Employees</th>
<th>NetWorth</th>
</tr>
<tr>
<td>
<table border="1" >
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh </td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir </td>
<td>7000</td>
</tr>
</table>
</td>
</tr>
</table>
Employees NetWorth
Name Salary
Ramesh 5000
Shabbir 7000
We can apply style to nested tables of HTML using CSS tag selector. Style written inside 'table' selector will
apply to both tables, while style written inside 'table table' selector will only apply on inner table.
Open Compiler
<!DOCTYPE html>
<html lang="en">
<head>
<style>
/* Common style for both tables */
table {
border-collapse: collapse;
width: 100%;
}
td,
th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
/* Styling inner table */
table table {
border: 2px solid #3498db;
width: 80%;
Safe and Effective Fat Removal Procedures…
margin: 10px auto;
Sponsored by: Fat Removal-non-m
}
table table td {
background-color: #ecf0f1;
border: 1px solid #bdc3c7;
}
</style>
</head>
<body>
<table border="1">
<tr>
<th>Employees</th>
<th>NetWorth</th>
</tr>
<tr>
<td>
<table border="1" >
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh </td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir </td>
<td>7000</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html> Safe and Effective Fat Removal Procedures…
Name Salary
Ramesh 5000
Shabbir 7000
Open Compiler
<!DOCTYPE html>
<html>
<head>
<style>
table{
border-collapse: collapse;
}
img{
height: 70px;
width: 200px;
}
</style>
</head>
<body>
<table border="1" width="100%">
<tr>
<th>Image </th> Safe and Effective Fat Removal Procedures…
<tr>
<td>
<img src="/images/logo.png">
</td>
<td>LOGO </td>
</tr>
<tr>
<td>
<img src="/html/images/html.jpg">
</td>
<td>HTML5 </td>
</tr>
</table>
</body>
</html>
Image Name
LOGO
HTML5
Organized Layouts: Nested tables enable the creation of organized and structured layouts, enhancing
the presentation of complex data.
Cell Customization: Each cell in a nested table can contain diverse content, including text, images, or
even additional nested tables.
Complex Designs: Achieve intricate design patterns by nesting tables within cells, providing flexibility
in webpage design.