问题
Recently I found that there is, possibly, a new way of commenting in HTML5.
Instead of the typical multi-line commenting I've read about, I thought I noticed that my IDE made a regular commented out. So I tested it out, and to my surprise Chrome had commented out that tag. It only commented out the tag and not the contents of the div, so I had to comment out the closer to avoid closing other divs.
I tested another and it appears that generally putting an exclamation marker in front of the opening of any tag, this symbol
Is this actually new? Is it bad practice? It is actually very convenient, but is it practical yet(if not new)?
Edit extra details:
Although a syntax error or misinterpretations of this particular syntax is a good reason, how come Chrome actually renders them as full comments?
The code is written as:
some text here that is still displayed
And then it is rendered as:
some text here that is still displayed
回答1:
There is no new standard for comments in HTML5. The only valid comment syntax is still . From section 8.1.6 of W3C HTML5:
Comments must start with the four character sequence U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS ( and into , exactly as described in the question.
On a final note, you can probably expect other HTML5-compliant parsers to behave the same as Chrome.
回答2:
I don't think this is a good habit to take since
Even if it doesn't appear, this seems not to be the correct syntax for commenting HTML code.
来源:https://stackoverflow.com/questions/29405858/does-html5-change-the-standard-for-html-commenting
495

被折叠的 条评论
为什么被折叠?



