<div> tag can not be used above <tr> tag. Instead you can use <tbody> tag to do your work. If you are planning to give id attribute to <div> tag and doing some processing, same purpose you can achieve through <tbody> tag. For further information visit this page

For example:

<table>
    <tbody class="green">
        <tr>
            <td>Data</td>
        </tr>
    </tbody>
    <tbody class="blue">
        <tr>
            <td>Data</td>
        </tr>
    </tbody>
</table>

secondly, you can put "div" tag inside "td" tag.

<table>
    <tr>
        <td>
            <div></div>
        </td>
    </tr>
</table>

Further questions are always welcome.

Answer from Aditya Ekbote on Stack Overflow
🌐
Webmaster World
webmasterworld.com › html › 3867431.htm
Div inside table? - HTML forum at WebmasterWorld - WebmasterWorld
You can't put a div inside a table, but you can put a div inside a table td. I know that's what you meant.
Discussions

How to put DIV between table rows? - HTML & CSS - SitePoint Forums | Web Development & Design Community
I have a table of a long list of information. If one row is clicked on I want to make that perticular one expand with extra stuff/elements without disrupting the display of the other elements: its hard to explain so I will try to explain it with the HTML below: EXPANDING UPON ROW 2 AT BLOCK LEVE... More on sitepoint.com
🌐 sitepoint.com
0
December 3, 2007
Why do people say that div's > tables?
Tables are slower to render. Modern HTML is not for appearance. It is for extensibility. Someone should be able to read your HTML and easily interpret what each section is. This isn't the case with tables, which are used for aesthetics not classification. You know what each is in this scenario. sidebar content is a lot harder to grasp. Why is the table there? It is not necessary. The table has nothing to do with classifying the sidebar and content. It has everything to do with aligning them, which is aesthetics, which is for CSS, not HTML. Are you familiar with XML readers? HTML should be able to be read and interpreted by an XML reader. A table to an XML reader - or even the average person - does not mean "a way to align content." It means tabular data - think Excel spreadsheets. However, an XML reader reading "a division of the page, classified as sidebar" makes perfect sense, even to a human. The best way to determine whether or not you are using the correct element is to imagine an XML reader trying to interpret it. Don't use it for aesthetics. Use it for classification. Your sidebar is a division, not the table cell of a spreadsheet. EDIT: Forgot . I also didn't mention why it is important to be semantically labelled correctly, which is why I'm surprised this has as many upvotes as it does. All I did was describe how to be semantically correct, but OP - and anyone else - should know why, as that is the question that was asked. I elaborated in a few comments. For those interested here is one of them. In short, you are not only coding for the sake of rendering the content to the page correctly. You are coding so that robots/crawlers/spiders/whatever can read just your code and understand what everything is. It is important that they can. More on reddit.com
🌐 r/webdev
151
26
July 22, 2011
How create table only using <div> tag and Css - HTML & CSS - SitePoint Forums | Web Development & Design Community
Tying to create a form without using tables for may layout I am using div’s & css’s I am uploading two files Line Up Page.html (5.7 KB) lineup2.php (4.5 KB) More on sitepoint.com
🌐 sitepoint.com
0
May 29, 2017
html - How create table only using <div> tag and CSS - Stack Overflow
Padding doesn't. And, while I haven't ... as Padding, in forcing and empty cell to be rendered properly. ... A bit OFF-TOPIC, but may help someone for a cleaner HTML... .common_table { display:table; border-collapse:collapse; border:1px solid grey; } .common_table DIV { display:table-row; ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
CSS-Tricks
css-tricks.com › using-divs-inside-tables
Using Divs Inside Tables | CSS-Tricks
July 2, 2015 - One important thing to remember when putting a div inside of a table is that the div needs to live inside of a particular table cell, meaning inside of a td or th element which is inside of a tr element.
🌐
SitePoint
sitepoint.com › html & css
How to put DIV between table rows? - HTML & CSS - SitePoint Forums | Web Development & Design Community
December 3, 2007 - I have a table of a long list of information. If one row is clicked on I want to make that perticular one expand with extra stuff/elements without disrupting the display of the other elements: its hard to explain so I will try to explain it with the HTML below: EXPANDING UPON ROW 2 AT BLOCK LEVE...
🌐
Reddit
reddit.com › r/webdev › why do people say that div's > tables?
r/webdev on Reddit: Why do people say that div's > tables?
July 22, 2011 -

I know this may sound like a stupid question, but I am a self-taught developer that's kinda just learning as I go.
I've been building alot of my websites using tables instead of div's... It was mentioned to me that using tables instead of div's is just "stupid".... Wasn't really given an explanation as to why, so I am just curious... Why?

EDIT: I've received some just amazing information you guys, thanks a ton!

Top answer
1 of 5
41
Tables are slower to render. Modern HTML is not for appearance. It is for extensibility. Someone should be able to read your HTML and easily interpret what each section is. This isn't the case with tables, which are used for aesthetics not classification. You know what each is in this scenario.
sidebar
content
is a lot harder to grasp. Why is the table there? It is not necessary. The table has nothing to do with classifying the sidebar and content. It has everything to do with aligning them, which is aesthetics, which is for CSS, not HTML. Are you familiar with XML readers? HTML should be able to be read and interpreted by an XML reader. A table to an XML reader - or even the average person - does not mean "a way to align content." It means tabular data - think Excel spreadsheets. However, an XML reader reading "a division of the page, classified as sidebar" makes perfect sense, even to a human. The best way to determine whether or not you are using the correct element is to imagine an XML reader trying to interpret it. Don't use it for aesthetics. Use it for classification. Your sidebar is a division, not the table cell of a spreadsheet. EDIT: Forgot . I also didn't mention why it is important to be semantically labelled correctly, which is why I'm surprised this has as many upvotes as it does. All I did was describe how to be semantically correct, but OP - and anyone else - should know why, as that is the question that was asked. I elaborated in a few comments. For those interested here is one of them. In short, you are not only coding for the sake of rendering the content to the page correctly. You are coding so that robots/crawlers/spiders/whatever can read just your code and understand what everything is. It is important that they can.
2 of 5
13
This is one of the best examples to demonstrate why using divs is superior than tables for structural markup http://www.csszengarden.com/ Edit: Learn CSS. You are lost without having a thorough understanding.
🌐
Divtable
divtable.com › generator
HTML Div Table Generator | 𝗗𝗜𝗩 𝗧𝗔𝗕𝗟𝗘.𝗖𝗢𝗠
Generate HTML Div table grids for websites in just a few easy steps. Set the options then select the desired size. Adjust the options in the interactive editors
🌐
Coderanch
coderanch.com › t › 119685 › languages › Table-nested-div
Table nested inside a div
I'm looking for a generic way to tell *any* table: "strech to fill your wrapping div", without putting any pixel-specifics into the table itself. 2. Note I set both the 'TBODY' and 'TABLE' to have 'height=100%'. It either of them is missing a height, then the table becomes even larger.
Find elsewhere
🌐
W3Schools
w3schools.com › html › html_div.asp
HTML Div Tutorial
How to use grid to align <div> elements side by side: <style> .grid-container { display: grid; grid-template-columns: 33% 33% 33%; } </style> London is the capital city of England. London has over 9 million inhabitants. Oslo is the capital city of Norway. Oslo has over 700,000 inhabitants. Rome is the capital city of Italy. Rome has over 4 million inhabitants. Try it Yourself » · Learn more about grid in our CSS grid tutorial. For a complete list of all available HTML tags, visit our HTML Tag Reference.
🌐
SitePoint
sitepoint.com › html & css
How create table only using <div> tag and Css - HTML & CSS - SitePoint Forums | Web Development & Design Community
May 29, 2017 - Tying to create a form without using tables for may layout I am using div’s & css’s I am uploading two files Line Up Page.html (5.7 KB) lineup2.php (4.5 KB) <a class=“attachment” This is what I have so far I have upl…
Top answer
1 of 11
302
.div-table {
  display: table;         
  width: auto;         
  background-color: #eee;         
  border: 1px solid #666666;         
  border-spacing: 5px; /* cellspacing:poor IE support for  this */
}
.div-table-row {
  display: table-row;
  width: auto;
  clear: both;
}
.div-table-col {
  float: left; /* fix for  buggy browsers */
  display: table-column;         
  width: 200px;         
  background-color: #ccc;  
}

Runnable snippet:

.div-table {
  display: table;         
  width: auto;         
  background-color: #eee;         
  border: 1px solid #666666;         
  border-spacing: 5px; /* cellspacing:poor IE support for  this */
}
.div-table-row {
  display: table-row;
  width: auto;
  clear: both;
}
.div-table-col {
  float: left; /* fix for  buggy browsers */
  display: table-column;         
  width: 200px;         
  background-color: #ccc;  
}
<body>
  <form id="form1">
      <div class="div-table">
             <div class="div-table-row">
                <div class="div-table-col" align="center">Customer ID</div>
                <div  class="div-table-col">Customer Name</div>
                <div  class="div-table-col">Customer Address</div>
             </div>
            <div class="div-table-row">
                  <div class="div-table-col">001</div>
                <div class="div-table-col">002</div>
                <div class="div-table-col">003</div>
            </div>
            <div class="div-table-row">
                <div class="div-table-col">xxx</div>
                <div class="div-table-col">yyy</div>
                <div class="div-table-col">www</div>
           </div>
            <div class="div-table-row">
                <div class="div-table-col">ttt</div>
                <div class="div-table-col">uuu</div>
                <div class="div-table-col">Mkkk</div>
           </div>

      </div>
  </form>
</body>

2 of 11
93

divs shouldn't be used for tabular data. That is just as wrong as using tables for layout.
Use a <table>. Its easy, semantically correct, and you'll be done in 5 minutes.

🌐
W3Schools
w3schools.com › html › html_table_styling.asp
HTML Table Styling
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › HTML › Reference › Elements › tbody
<tbody>: The Table Body element - HTML | MDN
December 17, 2025 - The <tbody> HTML element encapsulates a set of table rows (<tr> elements), indicating that they comprise the body of a table's (main) data.
🌐
W3Schools
w3schools.com › howto › howto_html_table_nested.asp
How To Create a Nested Table
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
GitHub
gist.github.com › danielpietzsch › 370754
How to align a HTML table inside a div · GitHub
How to align a HTML table inside a div · Raw · table_alignment.css · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
YouTube
m.youtube.com › watch
Learn HTML & CSS - HTML Tables, Divs, and Forms
Share your videos with friends, family, and the world
🌐
Inforest
inforest.com › home › news › how to create a responsive div table in bootstrap 4 (the easy way!)
How to Create a Responsive Div Table in Bootstrap 4 (The Easy Way!) - Inforest Communications
March 26, 2025 - So, what did we do? We leaned into the power of Bootstrap 4’s flexible grid system and styled div elements to look and feel like a table—without sacrificing responsiveness.
🌐
CSS-Tricks
css-tricks.com › complete-guide-table-element
HTML Table Element Guide | CSS-Tricks
August 12, 2024 - I frequently use table to display forms, in a three columns way : label, input field and help/info area, repeating lines to lines for each data… a more easy way to construct form. My hypothesis is than the data are tabulars, associated: each line is a coherent set (label / input / help) the entire form represent a way to input … a line in a database, so…) Some of my colleague said NO! It’s “old school”, you need to use ul / li / div …
🌐
CodeProject
codeproject.com › articles › DIV-TABLE
DIV TABLE - CodeProject
December 17, 2009 - This article demonstrates using div elements to effectively build websites without using table elements on a page.
🌐
EduGeek
edugeek.net › forums › web-development › 78142-replace-tables-div.html
Replace tables with div?
June 22, 2011 - Instead of using float: left; on the divs, use display: inline-block; Then in the container CSS, add text-align: center; and it should do the trick for you. Explanation if you like, but experimentation shows it working additional cells go onto the line below automatically and centered, although ...