w3c / w3c/csswg-drafts

[css-nesting][css-style-attr] Allow CSS nesting for inline styles

Open
#8,752 23 comments 14 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-nesting-1 css-nesting-2 css-style-attr-3
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

Whether CSS nesting works for inline styles isn't actually defined in the specs, as far as I can find.

So I was under the assumption that I could do:

<ul style="
   & a {
    font-weight:bold;
    &:link {color:green}
    &:is(:hover, :active) {color:red} 
  }">
  <li><a href="#">Home</a></li>
  <li><a href="#">Blog</a></li>
  <li><a href="#">About</a></li>
 </ul>

And found out that no, it doesn't work.

I'm hoping that this behaviour can be defined at the very least, and allowed if at all possible.

By allowing nesting to work with inline styles, it creates a very useful method to scope CSS styles.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with issue #8752 and its 23-comment discussion about CSS nesting in the style attribute. Review the CSS nesting and inline-style specifications referenced or discussed there; done means reaching a clear specification decision that defines whether nested inline styles are supported and how they behave.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.