Why can't the

tag contain a

tag inside it?

前端 未结 5 2112
小蘑菇
小蘑菇 2020-11-21 22:09

As far as I know, this is right:

some words

But this is wrong:

&l

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-21 22:58

    An authoritative place to look for allowed containment relations is the HTML spec. See, for example, http://www.w3.org/TR/html4/sgml/dtd.html. It specifies which elements are block elements and which are inline. For those lists, search for the section marked "HTML content models".

    For the P element, it specifies the following, which indicates that P elements are only allowed to contain inline elements.

    
    

    This is consistent with http://www.w3.org/TR/html401/struct/text.html#h-9.3.1, which says that the P element "cannot contain block-level elements (including P itself)."

提交回复
热议问题