query-feature

Size/orientation — CSS reference

Orientation compares the physical dimensions of the container, not the device orientation. Landscape means width is greater than height, while portrait includes equal dimensions.

Formal Syntax & Structure

css syntaxcss
@container (orientation: landscape) { /* descendant styles */ }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>size/orientation</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 (orientation: landscape){#a{color:rgb(0,100,0)}}</style><body><section id="box"><div id="a">Component</div></section></body></html>
CSS Reference