Is it really bad idea to group tr tags with div?

前端 未结 3 1301
伪装坚强ぢ
伪装坚强ぢ 2021-01-07 18:43

I\'m developing application with Backbone.js View class returns one element after rendering. It\'s ok if I use divs or spans. But problem starts when I start to render objec

3条回答
  •  抹茶落季
    2021-01-07 18:58

    Yes, it is a very bad idea.

    The HTML specification does not allow div elements to be child elements of a table element, so it triggers error recovery routines in browsers.

    Given this input:

    The DOM that Firefox will generate (and you can see this by using the Inspect Element feature) will look like this:

    1
    2
    3
    4
    5
    6
    1
    2
    3
    4
    5
    6

    Note that the div elements have been removed from the table and placed before it. This makes them useless for manipulating the rows.

    HTML provides the thead, tfoot and tbody elements to group table rows. Use the appropriate ones of those instead of div elements (you can have only one thead and only one tfoot, but there are no limits on the number of tbody elements).

提交回复
热议问题