Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add rules/haidong-once/cursor-rules-collection/302-css-best-practicesgit clone --depth 1 https://github.com/HaiDong-Once/cursor-rules-collectionWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/rules/haidong-once/cursor-rules-collection/302-css-best-practices)<a href="https://agentmods.dev/rules/haidong-once/cursor-rules-collection/302-css-best-practices"><img src="https://agentmods.dev/badge/rules/haidong-once/cursor-rules-collection/302-css-best-practices.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00000 | $0.02152 |
| Opus 5 | $0.00000 | $0.01076 |
| Sonnet 5 | $0.00000 | $0.00430 |
| Haiku 4.5 | $0.00000 | $0.00215 |
Grade A, and why
302-css-best-practices scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 400 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CSS最佳实践规范 (302)
规则概述
本规范定义了CSS的编码规范和最佳实践,旨在提高样式代码的可读性、可维护性和性能。
基本规范
1.1 代码格式
- 缩进使用2个空格(一个tab)
- 每个属性声明末尾都要加分号
- 选择器和声明块之间使用一个空格
- 每个属性单独一行
/* 推荐 */
.selector {
property1: value1;
property2: value2;
}
/* 不推荐 */
.selector{property1:value1;property2:value2;}
1.2 命名规范
- 类名使用有意义的命名,反映元素用途而非外观
- 使用连字符(-)作为类名中单词的分隔符
- 避免使用下划线(_)和驼峰式命名
- ID和类名小写
/* 推荐 */
.nav-item {
margin-right: 10px;
}
/* 不推荐 */
.navItem {
margin-right: 10px;
}
/* 不推荐 - 基于表现而非用途 */
.blue-button {
background-color: blue;
}
/* 推荐 - 基于用途 */
.btn-primary {
background-color: blue;
}
选择器规范
2.1 选择器性能
- 避免使用通配符选择器(*)
- 避免使用标签名作为选择器
- 使用直接子选择器优化性能
- 选择器嵌套层级不超过3层
/* 不推荐 - 标签选择器 */
div a span {
color: red;
}
/* 推荐 - 使用类选择器 */
.menu .menu-link .icon {
color: red;
}
/* 更好 - 使用直接子选择器减少层级 */
.menu > .menu-link > .icon {
color: red;
}
/* 最佳 - 扁平化选择器 */
.menu-icon {
color: red;
}
2.2 避免使用ID选择器
- 尽量使用类选择器,避免使用ID选择器(高特异性会导致样式难以覆盖)
/* 不推荐 */
#header {
padding: 20px;
}
/* 推荐 */
.header {
padding: 20px;
}
属性规范
3.1 属性顺序
按照特定的顺序组织属性,提高代码可读性:
- 布局属性(position, display, float 等)
- 盒模型属性(width, height, margin, padding 等)
- 视觉属性(background, border, box-shadow 等)
- 文字排版(color, font, text-align, text-transform 等)
- 其他属性
.element {
/* 布局属性 */
position: absolute;
display: block;
float: left;
/* 盒模型属性 */
width: 100px;
height: 100px;
margin: 10px;
padding: 10px;
/* 视觉属性 */
background: #f5f5f5;
border: 1px solid #e5e5e5;
border-radius: 3px;
/* 文字排版 */
color: #333;
font-size: 16px;
text-align: center;
/* 其他 */
cursor: pointer;
}
3.2 简写属性
- 尽量使用简写属性
- 省略值为0的单位
- 十六进制值使用小写字母,尽可能使用简写
/* 不推荐 */
.element {
margin-top: 0px;
margin-right: 10px;
margin-bottom: 20px;
margin-left: 10px;
background-color: #FFFFFF;
}
/* 推荐 */
.element {
margin: 0 10px 20px;
background-color: #fff;
}
组织规范
4.1 模块化CSS
- 采用模块化方式组织CSS,每个组件维护自己的样式
- 使用BEM命名约定(Block-Element-Modifier)提高可读性和可维护性
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 6d ago First seen · 400 lines · 0 tokens per session scan A c4b27cafee15
302-css-best-practices is a cursor rule published in the GitHub repository HaiDong-Once/cursor-rules-collection (24 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,152 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
css-styling
CSS architecture, tokens, and styling rules for this Docusaurus site. Apply when creating or modifying components, styles, layouts, or any UI-facing code.
codex-premium-website-skills
Apply Codex Skills standards to frontend, website, motion, accessibility, QA, agent reasoning, and handoff work.
shadcn-tailwind-guide
本规范定义了使用 shadcn/ui 和 Tailwind CSS 开发新组件的标准流程和最佳实践。.
ui-components
USE WHEN: Building UI components, structuring layouts, and applying styles using Tailwind CSS.
performance
Frontend performance optimization rules. Apply when optimizing UI or bundle.
css-render-blocking-diagnosis
Cursor rule "css-render-blocking-diagnosis" from adobecom/da-express-milo, covering css render-blocking diagnosis & resolution, critical learning from 98 pagespeed achievement, primary diagnostic protocol, step 1: css blocking symptom recognition and step 2: css loading sequence audit.