paragraph tag not closed?

后端 未结 2 1721
醉话见心
醉话见心 2021-01-22 11:34

I simplified my html code down to this



Who are

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-22 11:54

    There's a fixed set of elements, belonging to Phrasing content category, that can be children of

    element:

    Phrasing content is the text of the document, as well as elements that mark up that text at the intra-paragraph level. Runs of phrasing content form paragraphs.

    a abbr area (if it is a descendant of a map element) audio b bdi bdo br button 
    canvas cite code data datalist del dfn em embed i iframe img input ins
    kbd keygen label map mark math meter noscript object output 
    progress q ruby s samp script select small span strong sub sup svg
    template textarea time u var video wbr Text
    

    element, as many other block-level ones, doesn't belong here. In this case,

    element closes automatically. Quoting the docs:

    A p element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, div, dl, fieldset, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, nav, ol, p, pre, section, table, or ul, element, or if there is no more content in the parent element and the parent element is not an a element.

    In this particular case, the structure of DOM is as follows:

    Who are we?

    wersfgse

    ... and, as you can see, the end tag isn't really welcome. Actually, you should be grateful for Firefox DOM Inspector marking this error. )

提交回复
热议问题