Skip to content

Warning: Avoid Excessively Long CSS Selectors #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task
nasty23-star opened this issue Apr 21, 2025 · 1 comment
Closed
1 task

Warning: Avoid Excessively Long CSS Selectors #116

nasty23-star opened this issue Apr 21, 2025 · 1 comment
Labels

Comments

@nasty23-star
Copy link

Rule details

Overly long CSS selectors can negatively impact performance. Browsers evaluate selectors from right to left, meaning long chains require more processing. Deeply nested selectors (e.g., body div#container ul.nav li a) force the browser to check each level, slowing down rendering. While modern browsers optimize selector matching, unnecessary complexity still harms maintainability and scalability.

What type of rule is this?

Warns about a potential problem

Example code

/* Too specific and slow */  
body div#main-container section.blog article.post div.content p.text a.link {
margin-left: 20px;
}

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

No response

@nzakas
Copy link
Member

nzakas commented Apr 21, 2025

Thanks for the suggestion. "excessively long" isn't specific enough for a rule, and everyone's idea of what a too-long or too-complex selector is different.

This is really a subset of what we were discussing on #19

@nzakas nzakas closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2025
@github-project-automation github-project-automation bot moved this from Needs Triage to Complete in Triage Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Complete
Development

No branches or pull requests

2 participants