w3c / w3c/csswg-drafts

[css-display-4] Add inner and outer display properties

Open
#4,729 10 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-display-4
Dominant language
Bikeshed
Stars
4.9k
Forks
816
Avg merge
2d 18h
Merged PRs (30d)
24

Description

CSS display level 3 adds the great change of allowing controlling the inner and outer display of an element. However it does not give a way to control them independently.

e.g. Consider a web component with a shadow root that would like to lay out its internals:

<user-summary>
  <#shadow-root>
    <style>
      :host {
        display: block grid;
        grid:
          "avatar displayName" max-content
          "avatar userName" max-content
          / auto auto !important;
      }

      #avatar {
        grid-area: avatar;
      }

      #displayName {
        grid-area: displayName;
      }

      #userName {
        grid-area: userName;
      }
    </style>

    <img id="avatar" src="{{avatarSrc}}"/>
    <div class="name">{{displayName}}</div>
    <div class="username">{{userName}}</div>
  </#shadow-root>
</user-summary>

In this case the grid styling is important for the functionality of the component, however this comes with a couple caveats:

  • In order to style the outer display a user needs to know the internal inner display, e.g. user-summary { display: inline grid; }
  • Prevention of overriding the grid style using !important breaks the ability to make user-summary a different outer style

As such I'd like to propose adding display-inside/display-outside as individual properties, then the styles could be written as such:

:host {
  display-outside: block; /* Can override externally */
  display-inside: grid !important; /* Cannot override externally as it is necessary */
}

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 the CSS Display Level 3 discussion and the issue's shadow-root example; compare the proposed display-inside/display-outside properties with current handling of inner and outer display. Done means the Working Group has resolved the proposal and documented the resulting specification change or disposition.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.