本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)75k · #3031

specificity-management

できること

このスキルは、スタイルシートの高い詳細度のセレクター、深いネスト、不要な!importantを確認し、それらを簡単にします。スタイルが変えにくいと感じるフロントエンドの開発者向けです。

使う場面

  • ✓上書きしにくいスタイルシートを整理するようエージェントに頼むとき。
  • ✓開発者がスタイルを効かせるために!importantを追加し続けているとき。
  • ✓セレクターが詳細すぎたり深くネストされたりして、コンポーネントのスタイルが衝突しているとき。

スキルのリンク

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/specificity-management/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/specificity-management/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のスタイルシートには!importantやIDのセレクターがたくさんあり、変更するたびに何かが壊れます。簡単にしてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、IDによるスタイル、深くネストしたセレクター、不要な!importantを見つけます。それらをクラスのセレクターに置き換え、ネストを減らし、役立つ場合は:where()のような詳細度ゼロのパターンを使います。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Keep CSS specificity low and flat

High specificity creates an escalation problem — once you use an ID selector, you need another ID to override it. Developers respond with !important, which escalates further. Flat, low-specificity CSS is predictable: later rules and more-specific selectors win cleanly, and the cascade works as intended.

Quick Reference

  • Prefer class selectors over ID selectors for styling
  • Avoid nesting selectors more than 3 levels deep
  • Never use !important except as a last resort for utility overrides
  • Use :where() to apply styles with zero specificity

Check

Analyze the selectors in this CSS file for specificity issues: ID selectors used for styling, overly nested selectors, and unnecessary !important.

Fix

Flatten high-specificity selectors to use classes instead of IDs, reduce nesting depth, and remove unnecessary !important declarations.

Explain

Explain CSS specificity scoring, why high specificity causes maintenance problems, and how to keep specificity flat using classes and BEM.

Code Review

Review stylesheets, component styles, and responsive states related to Keep CSS specificity low and flat. 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/specificity-management

よくある質問

詳細度とは何ですか?

同じ要素に複数のルールが当たるとき、ブラウザーがどのルールを優先するかを決めるための点数です。

!importantはなぜ問題ですか?

このスキルによると、問題を悪化させるからです。次の上書きにもまた!importantが必要になることが多いためです。

BEMはどう役立ちますか?

このスキルによると、BEMのクラス名は詳細度を平らに保ち、カスケードを予測しやすくします。

詳細

作者による元の説明

Use when reviewing stylesheets, component styles, and responsive behavior related to Keep CSS specificity low and flat. Check the rendered layout across breakpoints and interaction states before proposing a fix.

repo: thedaviddias/Front-End-Checklist

人気

GitHubのスター
75k
ランキング
#3031
ライセンス
MIT
更新日
2026/10/31

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル