HTML 5: Is it
,
, or
?

后端 未结 29 3821
滥情空心
滥情空心 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:38

    IMHO it is better to use the regular notation (
    ) instead of the forgiving notation (
    ) for the following reasons:

    Consistency

    In your HTML there is probably some SVG and SVG only support the regular notation (e.g. ).

    Hackability

    It is not a case that frameworks like React and NativeScript use an XML notation.
    Your markup code will be easier to parse.

    Clarity

    The regular notation is easier to read and understand, even late at night.

    Specifications

    Both
    and
    are valid HTML tags.

    Conclusion

    If you use a full-fledged text editor configure it to use the regular notation (which is called XHTML by Emmet).
    For instance, in Visual Studio Code you just have to add the following line to your settings:

    "emmet.syntaxProfiles": {"html": "xhtml"}
    

提交回复
热议问题