Which lint rule helps prevent over-nested selectors that hinder maintainability?

Prepare for the CSS Mastery SAD Maintenance and CSA Stand Ups Test. With flashcards and multiple choice questions, ready yourself for the exam with hints and explanations for every question. Ace your exam today!

Multiple Choice

Which lint rule helps prevent over-nested selectors that hinder maintainability?

Explanation:
Deeply nested selectors make CSS harder to read, override, and maintain because each extra level adds specificity and coupling between components. A lint rule that enforces a maximum nesting depth directly addresses this by limiting how far selectors can descend into the DOM tree. Configuring a depth like 3–4 levels keeps selectors flatter, which tends to lead to clearer component boundaries and easier refactoring. This rule works well with component-based approaches and preprocessors, nudging you to extract styles into smaller, reusable pieces (components, utilities, or mixins) instead of piling on deeper descendant selectors. The other options address different maintainability concerns—ensuring uniqueness, targeting ID-specific selectors, or restricting to a single class per rule—but they don’t curb nesting depth in the same direct way.

Deeply nested selectors make CSS harder to read, override, and maintain because each extra level adds specificity and coupling between components. A lint rule that enforces a maximum nesting depth directly addresses this by limiting how far selectors can descend into the DOM tree. Configuring a depth like 3–4 levels keeps selectors flatter, which tends to lead to clearer component boundaries and easier refactoring.

This rule works well with component-based approaches and preprocessors, nudging you to extract styles into smaller, reusable pieces (components, utilities, or mixins) instead of piling on deeper descendant selectors. The other options address different maintainability concerns—ensuring uniqueness, targeting ID-specific selectors, or restricting to a single class per rule—but they don’t curb nesting depth in the same direct way.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy