Skip to content

[css-contain-3] Nesting Context (side effect / enhancement) #7209

Open
@jakob-e

Description

@jakob-e

Based on the current implementation in Chrome Canary and Safari TP Container Queries seems to only need a property name – allowing them to be used to expose nesting context.

  /* this works */
  .container-a {
    container-name: A;
    container-type: inline-size;
  }

  @container A (inline-size) {
    .child { color: orange; }
  }

IMO it makes a lot of sense to use Container Queries to handle this scenario (child styling without a direct reference to the container selector(s)).

If possible it would be nice if container-name could be used without having to specify container-type and query

  /* simplified syntax (suggestion) */
  .container-a {
    container-name: A;
  }

  @container A {
    .child { color: orange; }
  }

Codepen Example

I hope it makes sense and that I haven't overlooked existing issues
Thank you for your hard work – it is highly appreciated
😃

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions