HTML 5: Is it
,
, or
?

后端 未结 29 3976
滥情空心
滥情空心 2020-11-22 00:26

I\'ve tried checking other answers, but I\'m still confused — especially after seeing W3schools HTML 5 reference.

I thought HTML 4.01 was supposed to \"allow\" singl

29条回答
  •  南方客
    南方客 (楼主)
    2020-11-22 00:49

    Most of the cases in HTML, the tags are in pair. But for a line break you don't need a pair of tags. Therefore to indicate this, HTML uses
    format.
    is the right one. Use that format.


    tag has no end tag in HTML In XHTML, the
    tag must be properly closed, like this:

    In XML every tag must be closed. XHTML is an extension of XML, hence all the rules of XML must be followed for valid XHTML. Hence even empty tags (nodes without child nodes) like
    should be closed. XML has a short form called self closing tags for empty nodes. You can write

    as
    . Hence in XHTML
    is used.

    HTML is very lenient in this regard, and there is no such rule. So in HTML empty nodes like


    etc are written without the closing forward slash.

    HTML



    XHTML



    Not all tags can be self closed. For example, a tag like

提交回复
热议问题