开发者

HTML Comments Clarification

开发者 https://www.devze.com 2023-04-11 02:33 出处:网络
Can I use /* */ comment tags in html . If not why because they are com开发者_开发问答mon for comments ?No you cannot. You can use <!-- -->

Can I use /* */ comment tags in html .

If not why because they are com开发者_开发问答mon for comments ?


No you cannot. You can use <!-- -->

As to the second part of the question, I can't really help you there :)

EDIT - Just realized that /* */ wouldn't be tags at all, which would make sense as to why you can't use them,


No, you can't, because the specification says so:

HTML comments have the following syntax:

<!-- this is a comment --> <!-- and so is this one,
    which occupies more than one line -->

White space is not permitted between the markup declaration open delimiter(""). A common error is to include a string of hyphens ("---") within a comment. Authors should avoid putting two or more adjacent hyphens inside comments.

Information that appears between comments has no special meaning (e.g., character references are not interpreted as such).

Note that comments are markup.

That last line tells you why you can't use /* */ - because HTML comments are markup too, just like any other tag, and those "universal comments" would not be tags.


You need to use:

<!-- A Comment -->

in HTMl as far as I'm aware.

/*

*/

is not universal, although it is common for block comments

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号