embedded-or-inline-css
它能做什么
这项技能检查网页中直接写在 HTML 里的样式。适用于希望代码更清晰、更易维护的开发者。
适用场景
- ✓当页面的 HTML 中散落着很多 style 属性的时候。
- ✓当模板里有大段难以修改的样式代码的时候。
- ✓当你希望浏览器能在多个页面之间复用样式的时候。
技能链接
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/embedded-or-inline-css/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我把页面里的内联样式移到单独的样式表中。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会找出内联样式和内嵌样式,并建议把它们移到外部文件中。只保留首屏关键样式和动态值(例如 CSS 自定义属性)在页面内。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Avoid embedded and inline CSS
Inline CSS cannot be cached separately, increases HTML payload, breaks separation of concerns, and is harder to maintain in large codebases.
Quick Reference
- Move inline styles to external CSS files or CSS-in-JS
- Exception: critical CSS should be inlined for performance
- Exception: dynamic values (CSS custom properties) can be inline
- Inline CSS breaks caching and increases HTML size
Check
Verify that inline CSS and embedded styles are avoided except for valid use cases like critical CSS, dynamic styles, or performance optimization.
Fix
Move inline and embedded CSS to external stylesheets, keeping only critical above-the-fold CSS inline for performance optimization.
Explain
Explain why external CSS is preferred for maintainability, caching, and separation of concerns, with exceptions for critical CSS and dynamic styles.
Code Review
Review stylesheets, component styles, and responsive states related to Avoid embedded and inline CSS. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/embedded-or-inline-css
常见问题
为什么外部样式表更好?
浏览器可以单独缓存它们,HTML 也会更小,更易维护。
什么时候可以使用内联 CSS?
这项技能允许保留首屏关键样式以及动态值,例如 CSS 自定义属性。
它是否涵盖框架?
在框架项目中,这项技能提到 CSS-in-JS 可作为一种选择。
详情
作者的原始描述
Use when reviewing stylesheets, component styles, and responsive behavior related to Avoid embedded and inline CSS. Check the rendered layout across breakpoints and interaction states before proposing a fix.
热度
- GitHub 星标
- 75k
- 排名
- #2830
- 许可证
- MIT
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
frontendchecklist
75k使用命令行工具,依据 380 多条关于无障碍、速度、SEO 和安全的规则,检查前端代码和线上页面。
frontend-checklist-global
75k依据全部 386 条 Front-End Checklist 规则审查前端项目,并为发现的每个问题给出具体修复方法。
404-page
75k检查你的页面缺失提示是否提供有用的链接,并返回真正的 404 状态,帮助迷路的访客找到方向。
about-page
75k审查你的网站是否有清晰的关于页面,说明由谁运营,以建立访客和搜索引擎的信任。