Changes are coming to one of the core properties in CSS: the display property. We will be able to define how our elements are behaving when relating to their children and how they relate to their siblings.
The new syntax of the display property will accept two parameters <display-outside>
and <display-inside>
.
For example, when we are saying display: grid
we are basically saying two things:
- this element is a grid for its children
- and this element is a block for its siblings
So the full declaration can be display: block grid
.
The same with display inline-grid. It is a grid for its children and an inline for its siblings. So with the new syntax, it will become display: inline grid
.
In this Web docs Mozilla article we have the following table describing the correspondence between the old and new syntax.
Current value | New value |
block | block flow |
flow-root | block flow-root |
inline | inline flow |
inline-block | inline flow-root |
flex | block flex |
inline-flex | inline flex |
grid | block grid |
inline-grid | inline grid |
As a general rule if a <display-outside>
value is specified but <display-inside>
is omitted, the elementβs inner display type defaults to flow.
So far only Firefox fully implements this new syntax but I am looking forward to more support as I think it provides a clearer description of how an element behaves.
If you want to read more and you can take a look at this great article or Rachel Andrew or the below video:
π 50 Javascript, React and NextJs Projects
Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.
π 50 Javascript, React and NextJs Projects
Learn by doing with this FREE ebook! Not sure what to build? Dive in with 50 projects with project briefs and wireframes! Choose from 8 project categories and get started right away.