Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which elements are "valid" to place inside <td> tag?

I know that it's not a good idea to place div inside td, but what about span and other elements? Which elements are ok to place inside td and which are not and why?

Edit: The problem is that I have an old table layout and I need to make modifications there. To do so, I need to add elements inside td, so what elements will be the least evil to insert into <td>?

like image 607
dhblah Avatar asked Aug 23 '12 16:08

dhblah


People also ask

Which tags can be used inside TD?

With HTML, you can easily add HTML tag inside a table. The tag should open and close inside the <td> tag. For example, adding a paragraph <p>…

Can form tag be used inside TD tag?

It is valid to put a <form> tag inside a <table> tag. Editing note: tags wrapped as code so that the content reads as intended, but the answer should specify that while the form is inside the table, it cannot be a direct descendant: it must be a child of a cell.

When using an h3 tag inside any TD tag underline the h3 text?

thead is not h3 , if you use h3 inside td element, it is absolutely fine, but if you use h3 as a direct child to tr is invalid. You can always check here whether your markup is valid or not.


1 Answers

The HTML spec specifies which elements may be direct decendants of other elements.

The <td> element has a flow content content model, which means it can contain:

a abbr address area (if it is a descendant of a map element) article aside audio b bdi bdo blockquote br button canvas cite code command datalist del details dfn dialog div dl em embed fieldset figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr i iframe img input ins kbd keygen label map mark math menu meter nav noscript object ol output p pre progress q ruby s samp script section select small span strong style (if the scoped attribute is present) sub sup svg table textarea time u ul var video wbr text

like image 134
zzzzBov Avatar answered Oct 23 '22 11:10

zzzzBov