html5 standard,Does HTML5 change the standard for HTML commenting?

问题

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值