Which elements are “valid” to place inside tag?

后端 未结 2 1977
囚心锁ツ
囚心锁ツ 2021-02-12 19:39

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

相关标签:
2条回答
  • 2021-02-12 19:49

    The idea that you shouldn't put a div inside a table is more about using semantic markup with CSS to style the layout.

    That being said, <table> and its related elements should be used to display data in a tabular format. If it makes sense for one of the cells in the table to contain more complex markup, then so be it.

    In the past, <table> was used because it easily gave a website a grid layout, but this should now be done using CSS to allow your site to be more accessible.

    0 讨论(0)
  • 2021-02-12 19:55

    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

    0 讨论(0)
提交回复
热议问题