concept

Container query content box — CSS reference

Size features query the content box of the selected container, not the border box. Padding and border can increase the measured border-box width without changing the queried content width.

Formal Syntax & Structure

css syntaxcss
@container (width = 240px) { /* descendant styles */ }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>container-query-content-box</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}#box{width:240px;height:120px;padding:12px;border:5px solid;box-sizing:content-box;container-type:size}@container (width = 240px){#a{color:rgb(0,100,0)}}</style><body><section id="box"><div id="a">Component</div></section></body></html>
CSS Reference