Is it allowed to have a self-closing div tag in an html document?

后端 未结 1 1893
滥情空心
滥情空心 2020-12-21 07:51

This question refers specifically to a script tag. I think it applies also to a div, but I just want to make sure. Is this legal html or not?

相关标签:
1条回答
  • 2020-12-21 08:08

    No it isn't legal HTML.

    The div element is not described as an EMPTY element in the DTD (4.01).

    The definition doesn't have EMPTY:

    <!ELEMENT DIV - - (%flow;)*            -- generic language/style container -->
    <!ATTLIST DIV
      %attrs;                              -- %coreattrs, %i18n, %events --
      %reserved;                           -- reserved for possible future use --
      >
    

    Contrast with the definition for HR:

    <!ELEMENT HR - O EMPTY -- horizontal rule -->
    <!ATTLIST HR
      %attrs;                              -- %coreattrs, %i18n, %events --
      >
    
    0 讨论(0)
提交回复
热议问题