single line comment in HTML

后端 未结 5 2051
不知归路
不知归路 2021-01-31 01:05

Is there a way to comment out a single line in HTML using just an escape sequence at the start of the line? Similar to using # or // in other languages

5条回答
  •  广开言路
    2021-01-31 01:43

    TL;DR For conforming browsers, yes; but there are no conforming browsers, so no.

    According to the HTML 4 specification, hello--> is a perfectly valid comment. However, I've not found a browser which implements this correctly (i.e. per the specification) due to developers not knowing, nor following, the standards (as digitaldreamer pointed out).

    You can find the definition of a comment for HTML4 on the w3c's website: http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.4

    Another thing that many browsers get wrong is that -- > closes a comment just like -->.

提交回复
热议问题