property-value

display/contents — CSS reference

Suppresses an ordinary wrapper’s own box while its contents still generate boxes. Inheritance still follows the element tree. The wrapper’s padding and background no longer paint as a box. Unusual elements such as replaced controls have special behavior; browser accessibility bugs can remove wrapper semantics. Prefer testing before applying to semantic wrappers.

Formal Syntax & Structure

css syntaxcss
display: contents;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS flow layout lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}body{font:16px/20px sans-serif} #p{width:240px;background:#e6eef2} .tile{background:#c2e4d5} #a,#b{box-sizing:content-box}#p{display:flex;gap:10px}#a{display:contents;color:rgb(0,128,0);padding:30px}#c,#b{width:60px;height:20px}</style><body><div id="p"><div id="a"><span id="c">Child</span></div><span id="b">Peer</span></div></body></html>
CSS Reference