concept
Container query — CSS reference
A container query evaluates conditions against an eligible ancestor for each candidate element. Size conditions require an appropriate container-type; style queries can use ordinary elements. Use a wrapper to make a component responsive to the space it receives.
Formal Syntax & Structure
css syntaxcss
@container (inline-size >= 200px) { /* descendant styles */ }Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>container-query</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;container-type:size}@container (inline-size >= 200px){#a{color:rgb(0,100,0)}}</style><body><section id="box"><div id="a">Component</div></section></body></html>