Skip to content

[css-grid] Proposal: Ability to name grids and reference them from subgrids #1375

@meyerweb

Description

@meyerweb

As part of the subgrid discussion, I feel it could be very useful to name grids and reference them elsewhere. Here’s a quick top-of-mind rough sketch:

body {display: grid; grid-name: toplevel;
     grid-template-columns: 1fr repeat(12, min-content) 1fr;
     grid-gap: 0.5em;
     }
#main section.modules > :nth-child(1) {display: subgrid toplevel;
     grid-column: 2 / 4;
     }
#main section.modules > :nth-child(2) {display: subgrid toplevel;
     grid-column: 4 / 6;
     }

This would sidestep the need to display: subgrid every element along a DOM branch. There’s precedent for naming things that are referenced elsewhere (e.g., keyframe animations) so the idea isn’t alien, though the syntactical approach here might be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions