Files
vscode/.github/instructions/css-best-practices.instructions.md
T
Ben VillalobosandGitHub 8bf178e1e1 Create css best practices instructions file (#328524)
Create css best practices instructions with :has rule
2026-07-31 23:25:00 +00:00

610 B

description, applyTo
description applyTo
CSS best practices for selector performance and maintainable state styling. Use when writing or reviewing CSS. **/*.css

CSS Best Practices

Selectors

  • Avoid :has() selectors. Because their result depends on descendant state, DOM mutations can invalidate styles on ancestors and cause expensive style recalculation, especially when selectors are broadly scoped. Instead, represent the state explicitly with a class or data attribute on the smallest container you own, and scope selectors to that marker. Add and remove the marker together with the state it represents.