vs

前端 未结 5 2063
独厮守ぢ
独厮守ぢ 2020-12-18 22:37

I am trying to understand why is there a difference in how a browser displays

verses
?

Here is an example: The expected

5条回答
  •  失恋的感觉
    2020-12-18 23:02

    Mainly because

    is not valid HTML.

    If you have a look through the different doctypes you'll notice that div cannot be self closing.

    According to the W3C:

    A div element must have both a start tag and an end tag.

    Source: http://www.w3.org/TR/html-markup/div.html

    To include Chucks comment here also, a trailing slash in HTML does not a self closing tag make. Self closing tags using a trailing slash are a feature of XHTML, not HTML.

提交回复
热议问题