display: contents
display: contents makes an element generate no box: it disappears from the layout and its children behave as direct children of its parent.
- It is useful when a wrapper in the HTML stops its children from taking part in the container’s flex or grid.
- The element loses its background, border, padding and size, because it no longer has a box.
- Use it carefully on buttons, links or lists: some browsers have lost their meaning for screen readers.
Example
The container is a 3-column grid and children 2 and 3 sit inside a wrapper with the content class. With block the wrapper takes a single cell; with contents it disappears and its children take their own cells.
ResultLive
html
css