How to Create Nested tables within tables in HTML ?

HTML tables are very helpful in structuring the content in the form of rows and columns. But sometimes there is a need to add a table within a table. HTML supports this functionality and is known as the nesting of the tables. Tables can be nested together to create a table inside a table.

Note: The inner table always has to be placed between the ….. of the outer table.

Example 1:

Implementation of creating a nested table. The inner table is added to the second column of the first row of the first table i.e. inside the … tags of the outer table.

HTML

< meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title >Nested Tables display: flex; justify-content: center; align-items: center; flex-direction: column; height: 100vh; table table < border: 2px solid blue; padding: 10px; text-align: center; < h1 style = "color: green;" >GeeksforGeeks

Output:

Screenshot-2023-12-18-123452

Example 2:

HTML

< meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title >Nested Tables text-align: center; margin: 50px; color: green; border: 2px solid green; margin: 20px auto; table table < border: 2px solid blue; margin: 10px auto; padding: 10px; text-align: center; < h2 >GeeksforGeeks < p >< b >Nested tables < td >Main Table row 1 column 1 < td >Main Table column 2 < td >Inner Table row 1 column 1 < td >Inner Table row 1 column 2 < td >Inner Table row 2 column 1 < td >Inner Table row 2 column 2 < td >Inner Table row 3 column 1 < td >Inner Table row 3 column 2 < td >Main Table row 2 column 1 < td >Main Table row 2 column 2

Output:

Screenshot-2023-12-18-123722

Note: Nested tables can be slow to load, restrictive for layouts, and prevent a more flexible and functional web page. They are lesser recommended from the SEO perspective.

Like Article -->

Please Login to comment.

Similar Reads

How to pass the 2 $index values within nested ng-repeat in AngularJS ?

In AngularJS applications, we can create dynamic behavior by passing the $index values within the nested ng-repeat directives. In the application, the $index variable or value is nothing but the index of the current item or the product that is in the ng-repeat loop. We can pass these values using 2 different methods. So in this article, we will see

5 min read Spectre Tables Stripped tables

Tables are important elements of web development society. If you want to display some data then you will definitely require tables. Spectre tables are the same as HTML tables, here we will discuss the Spectre Stripped tables. Tables Stripped tables Class: table-stripped: This class is used to make the table row(odd one) stripped. Syntax: <table

1 min read Spectre Tables Scrollable tables

Tables are important elements of web development society. If you want to display some data then you will definitely require tables. Spectre tables are the same as HTML tables, here we will discuss the Spectre Scrollable tables. Tables Scrollable tables Class: table-scroll: This class is used to create the table row vertically scroll-able.Syntax:

1 min read How to create links to sections within the same page in HTML ?

We will explore how to create links within an HTML page that are linked to specific sections of the same page. Creating internal links in HTML enhances user experience by making navigation easier for website visitors. By using the id attribute and the <a> (anchor) tag, you can link to specific sections of a webpage, allowing quick access to n

2 min read Can we Create a Nested Form in HTML ?

In HTML nesting forms means placing one <form> element inside another is not allowed, although, multiple forms can be possible to create. The HTML specification explicitly specifies that forms cannot be nested. Nesting forms can lead to unexpected behavior and conflicts between forms. As a result, web browsers do not support the nesting of fo

3 min read What is nesting of list & how to create the nested list in HTML ?

Nesting of lists in HTML involves placing one list within another list item, creating a hierarchical structure. This is done by embedding a <ul> (unordered) or <ol> (ordered) list inside an <li> (list item) element. The proper way to make a nested HTML list is to use the <ul> or <ol> element as a child of the <li

2 min read How to create a nested webpage in HTML ?

When the content of one completely different webpage is embedded into another webpage, it is called a nested webpage. In simple words, a webpage that is inside another webpage of a completely different domain. In this article, we are going to learn how to create a nested webpage. There are two methods to create a nested webpage. Table of Content Us

2 min read How to create a form within dropdown menu using Bootstrap ?

A Dropdown menu is used to allow the user to choose the content from the menu as per their requirement and it is used to save screen space and avoid the long scrolling of the web pages. In web design, we often come in a scenario where we need to create a form within the dropdown menu to get some user data or to give access to specific content. Prer

3 min read How to get button toggle state within HTML?

Toggle buttons are basically on/off buttons. A button can be switched from on to off state and vice-versa. This process is called toggling.Examples of toggle button: The buttons on our switchboards are the best example of toggle buttons.Some of the buttons on our phones- the torch button, the mobile data button, the wifi button, flight mode, Blueto

2 min read How to add Flash content within a webpage in HTML?

Flash is a vector animation software that was created with the intention of creating animations for web pages. Because vector graphics are so light, they are perfect for the web. There are different ways to insert a Flash file in HTML. Method-1: Using object and embed tag: The web standard for embedding content on a web page is the <object> t

2 min read How to create Nested Accordion using Google AMP amp-accordion?

Introduction: Sometimes we have a lot of content to display and to make the website look pretty and short we make use of the collapsible textboxes. Collapsible textboxes are that division which is the combination of heading and content, generally only heading is visible but when it is hit the content is displayed. Setup: You have to import amp-acco

3 min read How to create nested controllers in Angular.js ?

A controller in AngularJS is a JavaScript object created with the help of a JavaScript object constructor. A controller can contain properties and functions. Controllers are used for controlling the application data of an AngularJS application. In this article, we will see the nested controllers in AngularJS and will understand their implementation

4 min read How to create an array with multiple objects having multiple nested key-value pairs in JavaScript ?

In this article, we will learn to create an array with multiple objects having key-value pairs, we will use nesting which means defining another array in a pre-defined array with key-value pairs. Suppose we have several arrays of objects means containing various key-value pairs where keys are uniquely identified now we have to add these arrays to a

3 min read How to Create Nested Classes in TypeScript ?

In TypeScript, you can create nested classes using different methods. We will discuss about three different approaches to creating nested classes in TypeScript. These are the approaches: Table of Content By defining nested classes inside a classBy using the namespacesBy using the modulesBy defining nested classes inside a classIn this approach, we

3 min read How to Create a Nested Object in JavaScript ?

JavaScript allows us to create objects having the properties of the other objects this process is called as nesting of objects. Nesting helps in handling complex data in a much more structured and organized manner by creating a hierarchical structure. These are the different methods to create nested objects in JavaScript are as follows: Table of Co

4 min read How to Create Nested Sub Menu using CSS ?

CSS Nested Sub-Menus refers to Dropdown Menus that are contained within another dropdown menu. These are commonly used in navigation menus to organize and structure content hierarchically. In this article, we are going to build a nested sub-menu using CSS, it will consist of a nav bar with various links such as Home, About Us, Contact, etc. Preview

3 min read How to Create Nested Arrays from a Nest of Arrays in JavaScript ?

Creating nested arrays from a nest of arrays in JavaScript involves organizing multiple arrays into a hierarchical structure, which is often useful for managing and representing complex data relationships. This process entails encapsulating arrays within other arrays to form multi-dimensional structures. Such nested arrays can represent various dat

3 min read How to Create a Union Type from Nested Array in TypeScript ?

TypeScript developers often encounter scenarios where they need to represent a value that could be one of several different types. TypeScript's union types provide a solution to this problem by allowing variables to hold values of multiple types. However, when dealing with nested arrays, each nested array might represent a different type, making it

3 min read How to Create A Nested Menus in Tailwind CSS?

TailwindCSS allows designers to create highly customizable and visually appealing interfaces using utility-first classes. With its extensive set of utilities, you can build nested menus that are both responsive and stylish. Tailwind's flexible styling options make it easy to design complex, nested menu structures without writing custom CSS. Prerequ

6 min read How to create Tables in Pug View Engine ?

Pug is a template engine for NodeJS and browsers, enabling dynamic content rendering. It compiles templates to HTML, supports JavaScript expressions for formatting, and facilitates the reuse of static pages with dynamic data. Its indentation-based syntax simplifies tag specification, enhancing readability. Tables in Pug:A table is an arrangement of

3 min read How to Create Responsive Tables in WordPress ?

In WordPress, creating responsive tables is crucial for providing a seamless user experience across various devices and screen sizes. Responsive tables ensure that the table content is easily readable and accessible, regardless of the device being used to access the website. These are the following approaches: Table of Content Using CSSUtilizing a

2 min read React.js Blueprint HTML Elements Component Nested Usage

React.js Blueprint is a front-end UI toolkit. It is very optimized and popular for building interfaces that are complex data-dense for desktop applications. We can add styles and the features of React.js BluePrint HTML elements Component to the HTML elements just by providing a className to the parent element, which will cha

2 min read Nested List in HTML

A nested list in HTML is a list that contains other lists within its list items. This creates a hierarchical structure, where each sublist is indented to visually represent its relationship to the parent list item. It's commonly used for organizing and presenting information in a structured manner, enhancing readability and clarity of content. Tabl

2 min read Design a Nested Chat Comments using HTML CSS and JavaScript

In this article, we will learn how to create Nested Comments using JavaScript. We must have seen it on social media like Facebook, Instagram, Youtube, Twitter, etc. We have seen the use of the nested comment in the comment section of these social sites. Approach: Create a folder nested-comments on your local machine and go to that folder.Create 3 f

2 min read How to Align Columns in Nested HTML using CSS Grid?

We can easily Align columns in nested HTML structures using a CSS grid. There are different approaches to do this such as Simple Nested Grid Alignment, Aligning Nested Grids with Specific Columns, and Responsive Nested Grids. Each approach serves different design needs, from basic grid layouts to more precise column alignments and responsive design

4 min read Why should we avoid use of tables for layout in HTML ?

In this article, we will learn why we should avoid using tables for layout in HTML. A website can be divided into various sections comprising of header, menus, content, and footer based on which there are many different layout designs available for developers. Different layouts can be created by using an HTML div tag and CSS property to style them.

4 min read What is the use of scope Attribute in HTML Tables ?

The "scope" attribute is a feature in HTML tables that allows you to specify the relationship between a header cell (th) and its associated data cells (td). This attribute provides useful information for assistive technologies, and it improves the accessibility and understanding of tabular data. Note: By using "scope", you can indicate whether a he

1 min read How to style HTML Tables with Tailwind CSS ?

TailwindCSS offers utilities to make tables visually appealing. The colored header table emphasizes visual hierarchy through background color, while the stripped row table improves readability with alternating row colors. Similarly, the hover effect table enhances user interaction by applying visual feedback on row hover, and the border to all rows

5 min read How to Style HTML Tables using Bootstrap ?

In Bootstrap, the styling of tables can be done to enhance their appearance and layout, using classes like table, table-hover, table-bordered, and more. These classes provide options for responsive design, color schemes, borders, and hover effects, making tables visually appealing and user-friendly. The below approaches can be used to style HTML ta

4 min read HTML Tables

HTML tables offer a powerful tool for presenting data on your website. But mastering them goes beyond just rows and columns. This article serves as your ultimate guide to unlocking the potential of HTML tables, stepping beyond the basics. Prerequisites: HTML Introduction Table of Content What is HTML Tables?HTML Table - Code ExampleTags used in HTM