Do you need to close meta and link tags in HTML?

前端 未结 2 647
太阳男子
太阳男子 2020-12-01 03:44

I was just reading somebody\'s HTML who never closed meta and link tags in the HTML head section. The code worked fine; is closing these tags optional?

I thought it

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-01 04:37

    It depends on the doctype. HTML5 doesn't need the closing. XHTML does.

    In HTML5, so-called void elements (elements that can't have content) don't need the closing, as they are self-closing. But it is still valid if you close them..

    Read more about it here: void-elements

提交回复
热议问题