Is a div inside a table allowed or not according to W3C?
No, you cannot insert a div directly inside of a table.
If you use a div in a td you will however get in a situation where it might be hard to predict how the elements will be sized. The default for a div is to determine its width from its parent, and the default for a table cell is to determine its size depending on the size of its content.
You can put div tags inside a td tag, but not directly inside a table or tr tag.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>test</title> </head> <body> <table> <tr> <td> <div>content</div> </td> </tr> </table> </body> </html>
This document was successfully checked as XHTML 1.0 Transitional!
You can't put a div
directly inside a table
, like this:
<!-- INVALID --> <table> <div> Hello World </div> </table>
Putting a div
inside a td
or th
element is fine, however:
<!-- VALID --> <table> <tr> <td> <div> Hello World </div> </td> </tr> </table>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With