gpt4 book ai didi

css - 在 CSS 中添加注释的语法是什么?

转载 作者:行者123 更新时间:2023-11-28 15:55:50 36 4
gpt4 key购买 nike

我们可以在 CSS 中以多少种方式和位置放置注释?

注释的放置会在 CSS 渲染和验证中造成任何问题吗?

最佳答案

CSS specification明确说明这一点:

Comments begin with the characters /* and end with the characters */. They may occur anywhere between tokens, and their contents have no influence on the rendering. Comments may not be nested.

CSS also allows the SGML comment delimiters (<!-- and -->) in certain places defined by the grammar, but they do not delimit CSS comments. They are permitted so that style rules appearing in an HTML source document (in the STYLE element) may be hidden from pre-HTML 3.2 user agents. See the HTML 4 specification ([HTML4]) for more information.

例如:

.row {background-color:#FFF;}  /* normal */
.row:hover {background-color:#CCC; /* grayed background */}

/* the title class */
.title{
/* make font bigger */
font-size: 160%;
}

关于css - 在 CSS 中添加注释的语法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2391223/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com