Why do browsers insert tbody element into table elements?

后端 未结 2 1441
攒了一身酷
攒了一身酷 2020-11-22 05:23

I was playing around with some ideas using raw html and JQuery. One thing I did was to create an table element with a set of rows.

相关标签:
2条回答
  • 2020-11-22 05:55

    Yes, tbody is the standard element indicating the body of a table. It is not required to put it in the markup, but it will be included in the DOM as you've seen.

    0 讨论(0)
  • 2020-11-22 06:12

    http://htmlhelp.com/reference/html40/tables/tbody.html:

    The TBODY element defines a group of data rows in a table. A TABLE must have one or more TBODY elements, which must follow the optional TFOOT. The TBODY end tag is always optional. The start tag is optional when the table contains only one TBODY and no THEAD or TFOOT.

    So there always is a tbody there (albeit sometimes with both the start and end tags optional and omitted), and the tools you are using are correct in showing it to you.

    thead or tfoot, on the other hand, are never present unless you explicitly include them, and if you do that, the tbody(s) must be explicit too.

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