Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which DOM elements can be child of tr?

Tags:

html

dom

I have problem becouse I want to surround some of td inside tr so I need to know.

Which DOM elements can be child of tr? (I know div cannot.)

like image 227
Mateusz Rogulski Avatar asked Sep 28 '12 06:09

Mateusz Rogulski


People also ask

What elements can a TR contain?

HTML tr element can reside within table element, th, col, colgroup, tbody elements.

Is TR a child of table?

The <tr> element may be a direct child of a <table> element or nested within a parent <thead>, <tfoot>, or <tbody> element.

Can a div be a child element?

html - div not allowed as child element of button - Stack Overflow. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.


2 Answers

W3C specify this stuff. For tr, you can find it here. Basically, only th and td elements can be direct contents of tr.

If you want other stuff inside your table, it has to go inside the td or th elements. For example, td can contain flow elements, including div.

like image 131
paxdiablo Avatar answered Oct 20 '22 03:10

paxdiablo


The HTML spec states:

Permitted contents

Zero or more of: one td element, or one th element

<tr> elements can contain only <td>s and <th>s.

like image 6
Blender Avatar answered Oct 20 '22 04:10

Blender