[{"data":1,"prerenderedAt":2466},["ShallowReactive",2],{"page-\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting":3,"content-all-pages":1903,"live-demo:cq-nested-card":2460},{"id":4,"title":5,"body":6,"description":1883,"extension":1884,"meta":1885,"navigation":120,"path":1899,"seo":1900,"stem":1901,"__hash__":1902},"content\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting\u002Findex.md","Container Queries Inside CSS Nesting: Keeping Responses Next to the Styles They Change",{"type":7,"value":8,"toc":1871},"minimark",[9,13,53,58,61,180,186,313,317,320,324,1268,1278,1285,1288,1355,1387,1401,1405,1411,1420,1426,1429,1433,1436,1477,1496,1500,1503,1733,1748,1752,1760,1764,1785,1808,1824,1836,1840,1868],[10,11,5],"h1",{"id":12},"container-queries-inside-css-nesting-keeping-responses-next-to-the-styles-they-change",[14,15,16,17,21,22,25,26,29,30,32,33,37,38,41,42,47,48,52],"p",{},"Before native nesting, a component's container queries lived at the top level of the stylesheet, often far below the component's base rules. Reading a card's styles meant scrolling between ",[18,19,20],"code",{},".card { … }",", ",[18,23,24],{},".card__title { … }"," and three ",[18,27,28],{},"@container"," blocks elsewhere in the file, then mentally reassembling which conditions changed which properties. Native CSS nesting lets ",[18,31,28],{}," sit ",[34,35,36],"em",{},"inside"," the rule it modifies, so each element's base style and its responsive variations live together. The narrow problem this page covers is doing that correctly: how the ",[18,39,40],{},"&"," selector resolves inside a nested query, what happens to specificity, and the one trap — an element querying itself — that nesting makes easier to fall into. It belongs to ",[43,44,46],"a",{"href":45},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002F","Container Query Syntax Basics"," in the ",[43,49,51],{"href":50},"\u002Fmastering-container-queries-responsive-layouts\u002F","Mastering Container Queries & Responsive Layouts"," guide.",[54,55,57],"h2",{"id":56},"why-nest-container-queries","Why nest container queries",[14,59,60],{},"Nesting is about locality. A developer changing how a card's title looks at wide sizes wants to see the title's base styles and its wide-size override in the same place. With nesting, the override is literally inside the title's rule.",[62,63,68],"pre",{"className":64,"code":65,"language":66,"meta":67,"style":67},"language-css shiki shiki-themes github-light-high-contrast github-dark-high-contrast",".card__title {\n  font-size: 1.1rem;\n  line-height: 1.3;\n\n  @container card (width > 30rem) {\n    font-size: 1.4rem;         \u002F* applies to .card__title *\u002F\n  }\n}\n","css","",[18,69,70,83,102,115,122,148,168,174],{"__ignoreMap":67},[71,72,75,79],"span",{"class":73,"line":74},"line",1,[71,76,78],{"class":77},"s-5SL",".card__title",[71,80,82],{"class":81},"suds8"," {\n",[71,84,86,89,92,95,99],{"class":73,"line":85},2,[71,87,88],{"class":77},"  font-size",[71,90,91],{"class":81},": ",[71,93,94],{"class":77},"1.1",[71,96,98],{"class":97},"sHUrx","rem",[71,100,101],{"class":81},";\n",[71,103,105,108,110,113],{"class":73,"line":104},3,[71,106,107],{"class":77},"  line-height",[71,109,91],{"class":81},[71,111,112],{"class":77},"1.3",[71,114,101],{"class":81},[71,116,118],{"class":73,"line":117},4,[71,119,121],{"emptyLinePlaceholder":120},true,"\n",[71,123,125,128,131,134,137,140,143,145],{"class":73,"line":124},5,[71,126,127],{"class":81},"  @",[71,129,130],{"class":77},"container",[71,132,133],{"class":77}," card",[71,135,136],{"class":81}," (",[71,138,139],{"class":77},"width",[71,141,142],{"class":81}," > 30",[71,144,98],{"class":77},[71,146,147],{"class":81},") {\n",[71,149,151,154,156,159,161,164],{"class":73,"line":150},6,[71,152,153],{"class":77},"    font-size",[71,155,91],{"class":81},[71,157,158],{"class":77},"1.4",[71,160,98],{"class":97},[71,162,163],{"class":81},";         ",[71,165,167],{"class":166},"sLBg1","\u002F* applies to .card__title *\u002F\n",[71,169,171],{"class":73,"line":170},7,[71,172,173],{"class":81},"  }\n",[71,175,177],{"class":73,"line":176},8,[71,178,179],{"class":81},"}\n",[14,181,182,183,185],{},"That reads as a single statement: \"the title is 1.1rem, or 1.4rem when the card is wider than 30rem.\" The same structure scales to many properties and several bands without the rules drifting apart as the stylesheet grows. It also makes deletion safe: removing the title's rule removes its responsive behaviour with it, instead of leaving an orphaned ",[18,184,28],{}," block that targets a selector nothing uses.",[187,188,194,195,194,199,194,203,194,211,194,223,194,229,194,238,194,244,194,247,194,251,194,255,194,259,194,262,194,266,194,271,194,274,194,277,194,281,194,285,194,290,194,295,194,299,194,302,194,306,194,310],"svg",{"viewBox":189,"role":190,"ariaLabel":191,"xmlns":192,"style":193},"0 0 720 300","img","Flat stylesheet with a component's base rules and container queries far apart, compared with nested rules keeping each element's variants together","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;height:auto;max-width:720px;margin:2rem 0","\n  ",[196,197,198],"title",{},"Flat versus nested organisation",[200,201,202],"desc",{},"Left, a flat stylesheet lists base rules for card, title and meta at the top and separate container query blocks at the bottom, with lines connecting each element to its distant overrides. Right, nested rules place each container query inside the element it modifies.",[204,205,210],"text",{"textAnchor":206,"x":207,"y":208,"style":209},"middle","360","26","text-anchor:middle;fill:currentColor;font:700 17px sans-serif","Where each element's responsive rules live",[212,213],"rect",{"x":214,"y":215,"width":216,"height":217,"rx":218,"fill":219,"stroke":220,"strokeWidth":221,"opacity":222},"40","46","280","226","10","none","currentColor","1.5","0.5",[204,224,228],{"textAnchor":206,"x":225,"y":226,"style":227},"180","68","text-anchor:middle;fill:currentColor;font:600 12px sans-serif","flat",[212,230],{"x":231,"y":232,"width":233,"height":234,"rx":235,"fill":236,"opacity":237},"56","80","248","24","4","#7aa2ff","0.3",[204,239,24],{"textAnchor":240,"x":241,"y":242,"style":243},"start","70","97","text-anchor:start;fill:currentColor;font:11px ui-monospace,monospace",[212,245],{"x":231,"y":246,"width":233,"height":234,"rx":235,"fill":236,"opacity":237},"110",[204,248,250],{"textAnchor":240,"x":241,"y":249,"style":243},"127",".card__meta { … }",[212,252],{"x":231,"y":253,"width":233,"height":234,"rx":235,"fill":219,"stroke":220,"opacity":254},"200","0.6",[204,256,258],{"textAnchor":240,"x":241,"y":257,"style":243},"217","@container (> 30rem) { title }",[212,260],{"x":231,"y":261,"width":233,"height":234,"rx":235,"fill":219,"stroke":220,"opacity":254},"232",[204,263,265],{"textAnchor":240,"x":241,"y":264,"style":243},"249","@container (> 30rem) { meta }",[267,268],"path",{"d":269,"fill":219,"stroke":236,"strokeWidth":270},"M310 92 C340 92 340 212 310 212","2",[267,272],{"d":273,"fill":219,"stroke":236,"strokeWidth":270},"M310 122 C330 122 330 244 310 244",[212,275],{"x":276,"y":215,"width":216,"height":217,"rx":218,"fill":219,"stroke":220,"strokeWidth":221,"opacity":222},"400",[204,278,280],{"textAnchor":206,"x":279,"y":226,"style":227},"540","nested",[212,282],{"x":283,"y":232,"width":233,"height":284,"rx":235,"fill":236,"opacity":237},"416","76",[204,286,289],{"textAnchor":240,"x":287,"y":288,"style":243},"430","99",".card__title {",[204,291,294],{"textAnchor":240,"x":292,"y":293,"style":243},"446","119","font-size: 1.1rem;",[204,296,298],{"textAnchor":240,"x":292,"y":297,"style":243},"139","@container (…) { … } }",[212,300],{"x":283,"y":301,"width":233,"height":284,"rx":235,"fill":236,"opacity":237},"166",[204,303,305],{"textAnchor":240,"x":287,"y":304,"style":243},"185",".card__meta {",[204,307,309],{"textAnchor":240,"x":292,"y":308,"style":243},"205","color: …;",[204,311,298],{"textAnchor":240,"x":292,"y":312,"style":243},"225",[54,314,316],{"id":315},"the-complete-implementation","The complete implementation",[14,318,319],{},"The card below keeps every container response inside the rule for the element it changes. Resize the demo to see the title, meta line and layout respond.",[321,322],"live-demo",{"name":323},"cq-nested-card",[62,325,329],{"className":326,"code":327,"language":328,"meta":67,"style":67},"language-html shiki shiki-themes github-light-high-contrast github-dark-high-contrast","\u003C!doctype html>\n\u003Chtml lang=\"en\">\n\u003Chead>\n\u003Cmeta charset=\"utf-8\">\n\u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\u003Ctitle>Nested container queries\u003C\u002Ftitle>\n\u003Cstyle>\n  body { font: 15px\u002F1.5 system-ui, sans-serif; margin: 1rem; }\n\n  \u002F* The wrapper is the container, never the element being styled. *\u002F\n  .card-slot {\n    container: card \u002F inline-size;\n  }\n\n  .card {\n    display: grid;\n    gap: 0.75rem;\n    padding: 1rem;\n    border: 1px solid #cbd5e1;\n    border-radius: 12px;\n\n    \u002F* Declarations directly inside apply to .card itself: the query\n       looks UP from .card and finds .card-slot. *\u002F\n    @container card (width > 32rem) {\n      grid-template-columns: 10rem 1fr;\n      padding: 1.5rem;\n    }\n  }\n\n  .card__media {\n    aspect-ratio: 16 \u002F 9;\n    border-radius: 8px;\n    background: linear-gradient(135deg, #c7d2fe, #818cf8);\n\n    @container card (width > 32rem) {\n      aspect-ratio: 1;\n    }\n  }\n\n  .card__title {\n    margin: 0;\n    font-size: 1.1rem;\n\n    @container card (width > 32rem) {\n      font-size: 1.35rem;\n    }\n  }\n\n  .card__meta {\n    margin: 0;\n    color: #475569;\n    font-size: 0.85rem;\n\n    \u002F* Nest selectors too: & is .card__meta. *\u002F\n    & time { font-variant-numeric: tabular-nums; }\n\n    @container card (width \u003C 20rem) {\n      \u002F* Hide the secondary meta on very narrow cards. *\u002F\n      & .card__author { display: none; }\n    }\n  }\n\u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cdiv class=\"card-slot\">\n    \u003Carticle class=\"card\">\n      \u003Cdiv class=\"card__media\" role=\"img\" aria-label=\"Abstract illustration\">\u003C\u002Fdiv>\n      \u003Cdiv>\n        \u003Ch3 class=\"card__title\">Designing for containers\u003C\u002Fh3>\n        \u003Cp class=\"card__meta\">\u003Cspan class=\"card__author\">Mira Chen\u003C\u002Fspan> · \u003Ctime>12 Sep\u003C\u002Ftime>\u003C\u002Fp>\n      \u003C\u002Fdiv>\n    \u003C\u002Farticle>\n  \u003C\u002Fdiv>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html",[18,330,331,346,365,374,391,415,428,437,485,490,496,504,513,518,523,531,544,559,573,593,608,613,619,625,646,666,680,686,691,696,704,723,737,770,775,794,806,811,816,821,829,842,855,860,879,894,899,904,909,917,928,941,955,960,966,987,992,1001,1007,1027,1032,1037,1047,1056,1066,1085,1103,1141,1150,1173,1220,1230,1240,1250,1259],{"__ignoreMap":67},[71,332,333,336,340,343],{"class":73,"line":74},[71,334,335],{"class":81},"\u003C!",[71,337,339],{"class":338},"sne4z","doctype",[71,341,342],{"class":77}," html",[71,344,345],{"class":81},">\n",[71,347,348,351,353,356,359,363],{"class":73,"line":85},[71,349,350],{"class":81},"\u003C",[71,352,328],{"class":338},[71,354,355],{"class":77}," lang",[71,357,358],{"class":81},"=",[71,360,362],{"class":361},"sT6z2","\"en\"",[71,364,345],{"class":81},[71,366,367,369,372],{"class":73,"line":104},[71,368,350],{"class":81},[71,370,371],{"class":338},"head",[71,373,345],{"class":81},[71,375,376,378,381,384,386,389],{"class":73,"line":117},[71,377,350],{"class":81},[71,379,380],{"class":338},"meta",[71,382,383],{"class":77}," charset",[71,385,358],{"class":81},[71,387,388],{"class":361},"\"utf-8\"",[71,390,345],{"class":81},[71,392,393,395,397,400,402,405,408,410,413],{"class":73,"line":124},[71,394,350],{"class":81},[71,396,380],{"class":338},[71,398,399],{"class":77}," name",[71,401,358],{"class":81},[71,403,404],{"class":361},"\"viewport\"",[71,406,407],{"class":77}," content",[71,409,358],{"class":81},[71,411,412],{"class":361},"\"width=device-width, initial-scale=1\"",[71,414,345],{"class":81},[71,416,417,419,421,424,426],{"class":73,"line":150},[71,418,350],{"class":81},[71,420,196],{"class":338},[71,422,423],{"class":81},">Nested container queries\u003C\u002F",[71,425,196],{"class":338},[71,427,345],{"class":81},[71,429,430,432,435],{"class":73,"line":170},[71,431,350],{"class":81},[71,433,434],{"class":338},"style",[71,436,345],{"class":81},[71,438,439,442,445,448,450,453,456,459,461,464,466,469,472,475,477,480,482],{"class":73,"line":176},[71,440,441],{"class":338},"  body",[71,443,444],{"class":81}," { ",[71,446,447],{"class":77},"font",[71,449,91],{"class":81},[71,451,452],{"class":77},"15",[71,454,455],{"class":97},"px",[71,457,458],{"class":81},"\u002F",[71,460,221],{"class":77},[71,462,463],{"class":77}," system-ui",[71,465,21],{"class":81},[71,467,468],{"class":77},"sans-serif",[71,470,471],{"class":81},"; ",[71,473,474],{"class":77},"margin",[71,476,91],{"class":81},[71,478,479],{"class":77},"1",[71,481,98],{"class":97},[71,483,484],{"class":81},"; }\n",[71,486,488],{"class":73,"line":487},9,[71,489,121],{"emptyLinePlaceholder":120},[71,491,493],{"class":73,"line":492},10,[71,494,495],{"class":166},"  \u002F* The wrapper is the container, never the element being styled. *\u002F\n",[71,497,499,502],{"class":73,"line":498},11,[71,500,501],{"class":77},"  .card-slot",[71,503,82],{"class":81},[71,505,507,510],{"class":73,"line":506},12,[71,508,509],{"class":77},"    container",[71,511,512],{"class":81},": card \u002F inline-size;\n",[71,514,516],{"class":73,"line":515},13,[71,517,173],{"class":81},[71,519,521],{"class":73,"line":520},14,[71,522,121],{"emptyLinePlaceholder":120},[71,524,526,529],{"class":73,"line":525},15,[71,527,528],{"class":77},"  .card",[71,530,82],{"class":81},[71,532,534,537,539,542],{"class":73,"line":533},16,[71,535,536],{"class":77},"    display",[71,538,91],{"class":81},[71,540,541],{"class":77},"grid",[71,543,101],{"class":81},[71,545,547,550,552,555,557],{"class":73,"line":546},17,[71,548,549],{"class":77},"    gap",[71,551,91],{"class":81},[71,553,554],{"class":77},"0.75",[71,556,98],{"class":97},[71,558,101],{"class":81},[71,560,562,565,567,569,571],{"class":73,"line":561},18,[71,563,564],{"class":77},"    padding",[71,566,91],{"class":81},[71,568,479],{"class":77},[71,570,98],{"class":97},[71,572,101],{"class":81},[71,574,576,579,581,583,585,588,591],{"class":73,"line":575},19,[71,577,578],{"class":77},"    border",[71,580,91],{"class":81},[71,582,479],{"class":77},[71,584,455],{"class":97},[71,586,587],{"class":77}," solid",[71,589,590],{"class":77}," #cbd5e1",[71,592,101],{"class":81},[71,594,596,599,601,604,606],{"class":73,"line":595},20,[71,597,598],{"class":77},"    border-radius",[71,600,91],{"class":81},[71,602,603],{"class":77},"12",[71,605,455],{"class":97},[71,607,101],{"class":81},[71,609,611],{"class":73,"line":610},21,[71,612,121],{"emptyLinePlaceholder":120},[71,614,616],{"class":73,"line":615},22,[71,617,618],{"class":166},"    \u002F* Declarations directly inside apply to .card itself: the query\n",[71,620,622],{"class":73,"line":621},23,[71,623,624],{"class":166},"       looks UP from .card and finds .card-slot. *\u002F\n",[71,626,628,631,633,635,637,639,642,644],{"class":73,"line":627},24,[71,629,630],{"class":81},"    @",[71,632,130],{"class":77},[71,634,133],{"class":77},[71,636,136],{"class":81},[71,638,139],{"class":77},[71,640,641],{"class":81}," > 32",[71,643,98],{"class":77},[71,645,147],{"class":81},[71,647,649,652,654,656,658,661,664],{"class":73,"line":648},25,[71,650,651],{"class":77},"      grid-template-columns",[71,653,91],{"class":81},[71,655,218],{"class":77},[71,657,98],{"class":97},[71,659,660],{"class":77}," 1",[71,662,663],{"class":97},"fr",[71,665,101],{"class":81},[71,667,669,672,674,676,678],{"class":73,"line":668},26,[71,670,671],{"class":77},"      padding",[71,673,91],{"class":81},[71,675,221],{"class":77},[71,677,98],{"class":97},[71,679,101],{"class":81},[71,681,683],{"class":73,"line":682},27,[71,684,685],{"class":81},"    }\n",[71,687,689],{"class":73,"line":688},28,[71,690,173],{"class":81},[71,692,694],{"class":73,"line":693},29,[71,695,121],{"emptyLinePlaceholder":120},[71,697,699,702],{"class":73,"line":698},30,[71,700,701],{"class":77},"  .card__media",[71,703,82],{"class":81},[71,705,707,710,712,715,718,721],{"class":73,"line":706},31,[71,708,709],{"class":77},"    aspect-ratio",[71,711,91],{"class":81},[71,713,714],{"class":77},"16",[71,716,717],{"class":81}," \u002F ",[71,719,720],{"class":77},"9",[71,722,101],{"class":81},[71,724,726,728,730,733,735],{"class":73,"line":725},32,[71,727,598],{"class":77},[71,729,91],{"class":81},[71,731,732],{"class":77},"8",[71,734,455],{"class":97},[71,736,101],{"class":81},[71,738,740,743,745,748,751,754,757,759,762,764,767],{"class":73,"line":739},33,[71,741,742],{"class":77},"    background",[71,744,91],{"class":81},[71,746,747],{"class":77},"linear-gradient",[71,749,750],{"class":81},"(",[71,752,753],{"class":77},"135",[71,755,756],{"class":97},"deg",[71,758,21],{"class":81},[71,760,761],{"class":77},"#c7d2fe",[71,763,21],{"class":81},[71,765,766],{"class":77},"#818cf8",[71,768,769],{"class":81},");\n",[71,771,773],{"class":73,"line":772},34,[71,774,121],{"emptyLinePlaceholder":120},[71,776,778,780,782,784,786,788,790,792],{"class":73,"line":777},35,[71,779,630],{"class":81},[71,781,130],{"class":77},[71,783,133],{"class":77},[71,785,136],{"class":81},[71,787,139],{"class":77},[71,789,641],{"class":81},[71,791,98],{"class":77},[71,793,147],{"class":81},[71,795,797,800,802,804],{"class":73,"line":796},36,[71,798,799],{"class":77},"      aspect-ratio",[71,801,91],{"class":81},[71,803,479],{"class":77},[71,805,101],{"class":81},[71,807,809],{"class":73,"line":808},37,[71,810,685],{"class":81},[71,812,814],{"class":73,"line":813},38,[71,815,173],{"class":81},[71,817,819],{"class":73,"line":818},39,[71,820,121],{"emptyLinePlaceholder":120},[71,822,824,827],{"class":73,"line":823},40,[71,825,826],{"class":77},"  .card__title",[71,828,82],{"class":81},[71,830,832,835,837,840],{"class":73,"line":831},41,[71,833,834],{"class":77},"    margin",[71,836,91],{"class":81},[71,838,839],{"class":77},"0",[71,841,101],{"class":81},[71,843,845,847,849,851,853],{"class":73,"line":844},42,[71,846,153],{"class":77},[71,848,91],{"class":81},[71,850,94],{"class":77},[71,852,98],{"class":97},[71,854,101],{"class":81},[71,856,858],{"class":73,"line":857},43,[71,859,121],{"emptyLinePlaceholder":120},[71,861,863,865,867,869,871,873,875,877],{"class":73,"line":862},44,[71,864,630],{"class":81},[71,866,130],{"class":77},[71,868,133],{"class":77},[71,870,136],{"class":81},[71,872,139],{"class":77},[71,874,641],{"class":81},[71,876,98],{"class":77},[71,878,147],{"class":81},[71,880,882,885,887,890,892],{"class":73,"line":881},45,[71,883,884],{"class":77},"      font-size",[71,886,91],{"class":81},[71,888,889],{"class":77},"1.35",[71,891,98],{"class":97},[71,893,101],{"class":81},[71,895,897],{"class":73,"line":896},46,[71,898,685],{"class":81},[71,900,902],{"class":73,"line":901},47,[71,903,173],{"class":81},[71,905,907],{"class":73,"line":906},48,[71,908,121],{"emptyLinePlaceholder":120},[71,910,912,915],{"class":73,"line":911},49,[71,913,914],{"class":77},"  .card__meta",[71,916,82],{"class":81},[71,918,920,922,924,926],{"class":73,"line":919},50,[71,921,834],{"class":77},[71,923,91],{"class":81},[71,925,839],{"class":77},[71,927,101],{"class":81},[71,929,931,934,936,939],{"class":73,"line":930},51,[71,932,933],{"class":77},"    color",[71,935,91],{"class":81},[71,937,938],{"class":77},"#475569",[71,940,101],{"class":81},[71,942,944,946,948,951,953],{"class":73,"line":943},52,[71,945,153],{"class":77},[71,947,91],{"class":81},[71,949,950],{"class":77},"0.85",[71,952,98],{"class":97},[71,954,101],{"class":81},[71,956,958],{"class":73,"line":957},53,[71,959,121],{"emptyLinePlaceholder":120},[71,961,963],{"class":73,"line":962},54,[71,964,965],{"class":166},"    \u002F* Nest selectors too: & is .card__meta. *\u002F\n",[71,967,969,972,975,977,980,982,985],{"class":73,"line":968},55,[71,970,971],{"class":81},"    & ",[71,973,974],{"class":77},"time",[71,976,444],{"class":81},[71,978,979],{"class":77},"font-variant-numeric",[71,981,91],{"class":81},[71,983,984],{"class":77},"tabular-nums",[71,986,484],{"class":81},[71,988,990],{"class":73,"line":989},56,[71,991,121],{"emptyLinePlaceholder":120},[71,993,995,998],{"class":73,"line":994},57,[71,996,997],{"class":97},"    @container",[71,999,1000],{"class":81}," card (width \u003C 20rem) {\n",[71,1002,1004],{"class":73,"line":1003},58,[71,1005,1006],{"class":166},"      \u002F* Hide the secondary meta on very narrow cards. *\u002F\n",[71,1008,1010,1013,1016,1018,1021,1023,1025],{"class":73,"line":1009},59,[71,1011,1012],{"class":81},"      & ",[71,1014,1015],{"class":77},".card__author",[71,1017,444],{"class":81},[71,1019,1020],{"class":77},"display",[71,1022,91],{"class":81},[71,1024,219],{"class":77},[71,1026,484],{"class":81},[71,1028,1030],{"class":73,"line":1029},60,[71,1031,685],{"class":81},[71,1033,1035],{"class":73,"line":1034},61,[71,1036,173],{"class":81},[71,1038,1040,1043,1045],{"class":73,"line":1039},62,[71,1041,1042],{"class":81},"\u003C\u002F",[71,1044,434],{"class":338},[71,1046,345],{"class":81},[71,1048,1050,1052,1054],{"class":73,"line":1049},63,[71,1051,1042],{"class":81},[71,1053,371],{"class":338},[71,1055,345],{"class":81},[71,1057,1059,1061,1064],{"class":73,"line":1058},64,[71,1060,350],{"class":81},[71,1062,1063],{"class":338},"body",[71,1065,345],{"class":81},[71,1067,1069,1072,1075,1078,1080,1083],{"class":73,"line":1068},65,[71,1070,1071],{"class":81},"  \u003C",[71,1073,1074],{"class":338},"div",[71,1076,1077],{"class":77}," class",[71,1079,358],{"class":81},[71,1081,1082],{"class":361},"\"card-slot\"",[71,1084,345],{"class":81},[71,1086,1088,1091,1094,1096,1098,1101],{"class":73,"line":1087},66,[71,1089,1090],{"class":81},"    \u003C",[71,1092,1093],{"class":338},"article",[71,1095,1077],{"class":77},[71,1097,358],{"class":81},[71,1099,1100],{"class":361},"\"card\"",[71,1102,345],{"class":81},[71,1104,1106,1109,1111,1113,1115,1118,1121,1123,1126,1129,1131,1134,1137,1139],{"class":73,"line":1105},67,[71,1107,1108],{"class":81},"      \u003C",[71,1110,1074],{"class":338},[71,1112,1077],{"class":77},[71,1114,358],{"class":81},[71,1116,1117],{"class":361},"\"card__media\"",[71,1119,1120],{"class":77}," role",[71,1122,358],{"class":81},[71,1124,1125],{"class":361},"\"img\"",[71,1127,1128],{"class":77}," aria-label",[71,1130,358],{"class":81},[71,1132,1133],{"class":361},"\"Abstract illustration\"",[71,1135,1136],{"class":81},">\u003C\u002F",[71,1138,1074],{"class":338},[71,1140,345],{"class":81},[71,1142,1144,1146,1148],{"class":73,"line":1143},68,[71,1145,1108],{"class":81},[71,1147,1074],{"class":338},[71,1149,345],{"class":81},[71,1151,1153,1156,1159,1161,1163,1166,1169,1171],{"class":73,"line":1152},69,[71,1154,1155],{"class":81},"        \u003C",[71,1157,1158],{"class":338},"h3",[71,1160,1077],{"class":77},[71,1162,358],{"class":81},[71,1164,1165],{"class":361},"\"card__title\"",[71,1167,1168],{"class":81},">Designing for containers\u003C\u002F",[71,1170,1158],{"class":338},[71,1172,345],{"class":81},[71,1174,1176,1178,1180,1182,1184,1187,1190,1192,1194,1196,1199,1202,1204,1207,1209,1212,1214,1216,1218],{"class":73,"line":1175},70,[71,1177,1155],{"class":81},[71,1179,14],{"class":338},[71,1181,1077],{"class":77},[71,1183,358],{"class":81},[71,1185,1186],{"class":361},"\"card__meta\"",[71,1188,1189],{"class":81},">\u003C",[71,1191,71],{"class":338},[71,1193,1077],{"class":77},[71,1195,358],{"class":81},[71,1197,1198],{"class":361},"\"card__author\"",[71,1200,1201],{"class":81},">Mira Chen\u003C\u002F",[71,1203,71],{"class":338},[71,1205,1206],{"class":81},"> · \u003C",[71,1208,974],{"class":338},[71,1210,1211],{"class":81},">12 Sep\u003C\u002F",[71,1213,974],{"class":338},[71,1215,1136],{"class":81},[71,1217,14],{"class":338},[71,1219,345],{"class":81},[71,1221,1223,1226,1228],{"class":73,"line":1222},71,[71,1224,1225],{"class":81},"      \u003C\u002F",[71,1227,1074],{"class":338},[71,1229,345],{"class":81},[71,1231,1233,1236,1238],{"class":73,"line":1232},72,[71,1234,1235],{"class":81},"    \u003C\u002F",[71,1237,1093],{"class":338},[71,1239,345],{"class":81},[71,1241,1243,1246,1248],{"class":73,"line":1242},73,[71,1244,1245],{"class":81},"  \u003C\u002F",[71,1247,1074],{"class":338},[71,1249,345],{"class":81},[71,1251,1253,1255,1257],{"class":73,"line":1252},74,[71,1254,1042],{"class":81},[71,1256,1063],{"class":338},[71,1258,345],{"class":81},[71,1260,1262,1264,1266],{"class":73,"line":1261},75,[71,1263,1042],{"class":81},[71,1265,328],{"class":338},[71,1267,345],{"class":81},[14,1269,1270,1271,1273,1274,1277],{},"Each nested ",[18,1272,28],{}," block without a selector applies its declarations to the enclosing rule's element. Where the change targets a descendant, ",[18,1275,1276],{},"& .card__author"," inside the query reaches it. The resulting CSS is exactly what the flat version would produce; nesting changes only how it is written.",[54,1279,1281,1282,1284],{"id":1280},"the-key-technique-how-and-bare-declarations-resolve","The key technique: how ",[18,1283,40],{}," and bare declarations resolve",[14,1286,1287],{},"Two forms appear inside a nested conditional rule, and they resolve differently.",[187,1289,194,1292,194,1295,194,1298,194,1301,194,1308,194,1312,194,1317,194,1321,194,1324,194,1327,194,1331,194,1333,194,1339,194,1342,194,1345,194,1349,194,1351],{"viewBox":1290,"role":190,"ariaLabel":1291,"xmlns":192,"style":193},"0 0 720 280","Two nested forms: bare declarations inside @container apply to the parent selector, and & followed by a descendant selector targets a descendant",[196,1293,1294],{},"What a nested @container expands to",[200,1296,1297],{},"Left: .card__meta containing @container with a bare declaration expands to @container { .card__meta { declaration } }. Right: .card__meta containing @container with & .card__author expands to @container { .card__meta .card__author { declaration } }.",[204,1299,1300],{"textAnchor":206,"x":207,"y":208,"style":209},"Nested source and its flat equivalent",[212,1302],{"x":1303,"y":1304,"width":1305,"height":1306,"rx":218,"fill":236,"opacity":1307},"30","50","320","100","0.2",[204,1309,1311],{"textAnchor":240,"x":215,"y":284,"style":1310},"text-anchor:start;fill:currentColor;font:12px ui-monospace,monospace",".x { @container (…) {",[204,1313,1316],{"textAnchor":240,"x":1314,"y":1315,"style":1310},"62","98","color: red;",[204,1318,1320],{"textAnchor":240,"x":215,"y":1319,"style":1310},"120","} }",[212,1322],{"x":1323,"y":1304,"width":1305,"height":1306,"rx":218,"fill":236,"opacity":1307},"370",[204,1325,1311],{"textAnchor":240,"x":1326,"y":284,"style":1310},"386",[204,1328,1330],{"textAnchor":240,"x":1329,"y":1315,"style":1310},"402","& .y { color: red; }",[204,1332,1320],{"textAnchor":240,"x":1326,"y":1319,"style":1310},[204,1334,1338],{"textAnchor":206,"x":1335,"y":1336,"style":1337},"190","176","text-anchor:middle;fill:currentColor;font:12px sans-serif","expands to",[204,1340,1338],{"textAnchor":206,"x":1341,"y":1336,"style":1337},"530",[212,1343],{"x":1303,"y":1335,"width":1305,"height":1344,"rx":218,"fill":219,"stroke":220,"strokeWidth":221,"opacity":254},"60",[204,1346,1348],{"textAnchor":206,"x":1335,"y":217,"style":1347},"text-anchor:middle;fill:currentColor;font:12px ui-monospace,monospace","@container (…) { .x { color: red } }",[212,1350],{"x":1323,"y":1335,"width":1305,"height":1344,"rx":218,"fill":219,"stroke":220,"strokeWidth":221,"opacity":254},[204,1352,1354],{"textAnchor":206,"x":1341,"y":217,"style":1353},"text-anchor:middle;fill:currentColor;font:11px ui-monospace,monospace","@container (…) { .x .y { color: red } }",[14,1356,1357,1358,1361,1362,1365,1366,1369,1370,1373,1374,1376,1377,1379,1380,1382,1383,1386],{},"The container lookup always starts from the element the final selector matches. For bare declarations that is the enclosing element; for ",[18,1359,1360],{},"& .y"," it is ",[18,1363,1364],{},".y",". Both look ",[34,1367,1368],{},"upward"," for a container, which is where the classic trap reappears: if ",[18,1371,1372],{},".card"," is itself the container and you nest a bare-declaration ",[18,1375,28],{}," inside ",[18,1378,1372],{},", the query looks for a container above ",[18,1381,1372],{},", finds none (or the wrong one), and never matches. Nesting makes this easy to write by accident, because the container declaration and the query sit a few lines apart in the same rule. Keep the container on a wrapper, as the example does with ",[18,1384,1385],{},".card-slot",", and the problem cannot arise.",[14,1388,1389,1390,1392,1393,1396,1397,1400],{},"Specificity follows the nesting rules: a nested selector behaves as if ",[18,1391,40],{}," were ",[18,1394,1395],{},":is(\u003Cparent selectors>)",". For a single class parent the result is identical to the flat equivalent. If the parent is a list such as ",[18,1398,1399],{},".card, #featured",", every nested rule inherits the ID's weight, which is a good reason to keep component parents to a single class.",[54,1402,1404],{"id":1403},"migrating-a-flat-stylesheet-to-nested-queries","Migrating a flat stylesheet to nested queries",[14,1406,1407,1408,1410],{},"Converting an existing component from top-level ",[18,1409,28],{}," blocks to nested ones is mechanical, and because the output is equivalent, it can be verified precisely.",[14,1412,1413,1414,1416,1417,1419],{},"Take one ",[18,1415,28],{}," block at a time. For each rule inside it, find the matching base rule for the same selector and move the declarations into a nested ",[18,1418,28],{}," with the same condition inside that base rule. Where a block contains rules for several elements, it splits into several nested queries — one per element — each repeating the condition. That repetition is the price of locality, and it is usually worth paying; where it is not, the token approach below removes it.",[14,1421,1422,1423,1425],{},"Check the order carefully. In a flat stylesheet, a later top-level ",[18,1424,28],{}," block overrides an earlier one when both match. After nesting, the relative order of nested queries within a rule decides precedence instead. If two bands overlapped in the flat version and relied on source order to resolve, nesting can reverse the winner. Converting the conditions to non-overlapping range syntax first removes the ambiguity entirely.",[14,1427,1428],{},"Finally, compare computed styles. Chromium's Computed pane and Firefox's rules view both show which rule supplied each value; checking a handful of elements at each band before and after the migration confirms nothing changed. A visual regression test at three container widths does the same automatically.",[54,1430,1432],{"id":1431},"organising-nested-queries-in-a-component-file","Organising nested queries in a component file",[14,1434,1435],{},"Nesting invites deep indentation. A few conventions keep nested component files readable:",[1437,1438,1439,1447,1453,1463],"ul",{},[1440,1441,1442,1446],"li",{},[1443,1444,1445],"strong",{},"One level of element nesting."," Nest element states and descendants of a component one level deep; avoid chains of nested selectors that mirror the DOM, which recreate the specificity problems methodologies such as BEM exist to prevent.",[1440,1448,1449,1452],{},[1443,1450,1451],{},"Queries last inside each rule."," Base declarations first, nested selectors next, conditional rules last. The eye reads the default before the variations.",[1440,1454,1455,1458,1459,1462],{},[1443,1456,1457],{},"Named containers."," Always name the container in component queries (",[18,1460,1461],{},"@container card …",") so nested rules cannot silently bind to an unrelated ancestor container when the component is embedded elsewhere.",[1440,1464,1465,1468,1469,1471,1472,1476],{},[1443,1466,1467],{},"Shared bands as tokens."," If several elements change at the same band, consider setting custom properties in one nested query on the component root and reading them in descendants, rather than repeating the same ",[18,1470,28],{}," condition in every element's rule. The token approach is shown in ",[43,1473,1475],{"href":1474},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators\u002F","Container Query Range Syntax and Logic",".",[14,1478,1479,1480,21,1483,1486,1487,1490,1491,1495],{},"The same nesting works for ",[18,1481,1482],{},"@media",[18,1484,1485],{},"@supports"," and ",[18,1488,1489],{},"@starting-style",", so an element's entry animation can live inside its rule as well. That makes nesting particularly effective for components with both layout and motion variants — see ",[43,1492,1494],{"href":1493},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances\u002F","Container Query Hover Affordances"," for motion that changes with container size.",[54,1497,1499],{"id":1498},"variation-nesting-inside-cascade-layers","Variation: nesting inside cascade layers",[14,1501,1502],{},"Component files often sit inside a cascade layer. Nesting and layers compose naturally: the layer wraps the component, the component wraps its element rules, and each element rule wraps its queries.",[62,1504,1506],{"className":64,"code":1505,"language":66,"meta":67,"style":67},"@layer components {\n  .card-slot { container: card \u002F inline-size; }\n\n  .card {\n    display: grid;\n    gap: 0.75rem;\n\n    @container card (width > 32rem) {\n      grid-template-columns: 10rem 1fr;\n    }\n\n    &:focus-within {\n      outline: 2px solid #4f46e5;\n      outline-offset: 3px;\n    }\n\n    @media (prefers-reduced-motion: no-preference) {\n      transition: box-shadow 150ms ease;\n      &:hover { box-shadow: 0 8px 24px rgb(15 23 42 \u002F 0.12); }\n    }\n  }\n}\n",[18,1507,1508,1516,1527,1531,1537,1547,1559,1563,1581,1597,1601,1605,1615,1633,1647,1651,1655,1663,1674,1721,1725,1729],{"__ignoreMap":67},[71,1509,1510,1513],{"class":73,"line":74},[71,1511,1512],{"class":97},"@layer",[71,1514,1515],{"class":81}," components {\n",[71,1517,1518,1520,1522,1524],{"class":73,"line":85},[71,1519,501],{"class":77},[71,1521,444],{"class":81},[71,1523,130],{"class":77},[71,1525,1526],{"class":81},": card \u002F inline-size; }\n",[71,1528,1529],{"class":73,"line":104},[71,1530,121],{"emptyLinePlaceholder":120},[71,1532,1533,1535],{"class":73,"line":117},[71,1534,528],{"class":77},[71,1536,82],{"class":81},[71,1538,1539,1541,1543,1545],{"class":73,"line":124},[71,1540,536],{"class":77},[71,1542,91],{"class":81},[71,1544,541],{"class":77},[71,1546,101],{"class":81},[71,1548,1549,1551,1553,1555,1557],{"class":73,"line":150},[71,1550,549],{"class":77},[71,1552,91],{"class":81},[71,1554,554],{"class":77},[71,1556,98],{"class":97},[71,1558,101],{"class":81},[71,1560,1561],{"class":73,"line":170},[71,1562,121],{"emptyLinePlaceholder":120},[71,1564,1565,1567,1569,1571,1573,1575,1577,1579],{"class":73,"line":176},[71,1566,630],{"class":81},[71,1568,130],{"class":77},[71,1570,133],{"class":77},[71,1572,136],{"class":81},[71,1574,139],{"class":77},[71,1576,641],{"class":81},[71,1578,98],{"class":77},[71,1580,147],{"class":81},[71,1582,1583,1585,1587,1589,1591,1593,1595],{"class":73,"line":487},[71,1584,651],{"class":77},[71,1586,91],{"class":81},[71,1588,218],{"class":77},[71,1590,98],{"class":97},[71,1592,660],{"class":77},[71,1594,663],{"class":97},[71,1596,101],{"class":81},[71,1598,1599],{"class":73,"line":492},[71,1600,685],{"class":81},[71,1602,1603],{"class":73,"line":498},[71,1604,121],{"emptyLinePlaceholder":120},[71,1606,1607,1610,1613],{"class":73,"line":506},[71,1608,1609],{"class":81},"    &",[71,1611,1612],{"class":77},":focus-within",[71,1614,82],{"class":81},[71,1616,1617,1620,1622,1624,1626,1628,1631],{"class":73,"line":515},[71,1618,1619],{"class":77},"      outline",[71,1621,91],{"class":81},[71,1623,270],{"class":77},[71,1625,455],{"class":97},[71,1627,587],{"class":77},[71,1629,1630],{"class":77}," #4f46e5",[71,1632,101],{"class":81},[71,1634,1635,1638,1640,1643,1645],{"class":73,"line":520},[71,1636,1637],{"class":77},"      outline-offset",[71,1639,91],{"class":81},[71,1641,1642],{"class":77},"3",[71,1644,455],{"class":97},[71,1646,101],{"class":81},[71,1648,1649],{"class":73,"line":525},[71,1650,685],{"class":81},[71,1652,1653],{"class":73,"line":533},[71,1654,121],{"emptyLinePlaceholder":120},[71,1656,1657,1660],{"class":73,"line":546},[71,1658,1659],{"class":97},"    @media",[71,1661,1662],{"class":81}," (prefers-reduced-motion: no-preference) {\n",[71,1664,1665,1668,1671],{"class":73,"line":561},[71,1666,1667],{"class":81},"      transition: ",[71,1669,1670],{"class":338},"box-shadow",[71,1672,1673],{"class":81}," 150ms ease;\n",[71,1675,1676,1679,1682,1684,1686,1688,1690,1693,1695,1698,1700,1703,1705,1707,1710,1713,1715,1718],{"class":73,"line":575},[71,1677,1678],{"class":81},"      &",[71,1680,1681],{"class":77},":hover",[71,1683,444],{"class":81},[71,1685,1670],{"class":77},[71,1687,91],{"class":81},[71,1689,839],{"class":77},[71,1691,1692],{"class":77}," 8",[71,1694,455],{"class":97},[71,1696,1697],{"class":77}," 24",[71,1699,455],{"class":97},[71,1701,1702],{"class":77}," rgb",[71,1704,750],{"class":81},[71,1706,452],{"class":77},[71,1708,1709],{"class":77}," 23",[71,1711,1712],{"class":77}," 42",[71,1714,717],{"class":81},[71,1716,1717],{"class":77},"0.12",[71,1719,1720],{"class":81},"); }\n",[71,1722,1723],{"class":73,"line":595},[71,1724,685],{"class":81},[71,1726,1727],{"class":73,"line":610},[71,1728,173],{"class":81},[71,1730,1731],{"class":73,"line":615},[71,1732,179],{"class":81},[14,1734,1735,1736,1739,1740,1743,1744,1476],{},"Layer order still decides precedence between layers, so a nested container query in ",[18,1737,1738],{},"components"," cannot override a rule in a later ",[18,1741,1742],{},"utilities"," layer, regardless of how specific it is. That combination — nesting for locality, layers for precedence — is the structure recommended in ",[43,1745,1747],{"href":1746},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens\u002F","Cascade Layers for Reset and Tokens",[54,1749,1751],{"id":1750},"browser-support","Browser support",[14,1753,1754,1755,1486,1757,1759],{},"Native CSS nesting, including nested conditional group rules such as ",[18,1756,28],{},[18,1758,1482],{},", is supported in current versions of Chrome, Edge, Firefox and Safari. Container queries require Chrome and Edge 105+, Firefox 110+ or Safari 16+, and cascade layers Chrome and Edge 99+, Firefox 97+ or Safari 15.4+. For older browsers, a build step can flatten nested CSS into the equivalent top-level rules; the output is identical in behaviour.",[54,1761,1763],{"id":1762},"faq","FAQ",[14,1765,1766,1772,1773,21,1775,1486,1777,1779,1780,1782,1783,1476],{},[1443,1767,1768,1769,1771],{},"Can ",[18,1770,28],{}," be nested inside a CSS rule?","\nYes. With native CSS nesting, conditional group rules such as ",[18,1774,28],{},[18,1776,1482],{},[18,1778,1485],{}," can be placed inside a style rule. Declarations directly inside the nested ",[18,1781,28],{}," apply to the parent selector, as if written with ",[18,1784,40],{},[14,1786,1787,1793,1794,1797,1798,1800,1801,1803,1804,1807],{},[1443,1788,1789,1790,1792],{},"What does ",[18,1791,40],{}," mean inside a nested container query?","\nIt refers to the selector of the enclosing style rule. In ",[18,1795,1796],{},".card { @container (width > 30rem) { & .title { … } } }",", the ",[18,1799,40],{}," stands for ",[18,1802,1372],{},", so the rule targets ",[18,1805,1806],{},".card .title"," when the container condition matches.",[14,1809,1810,1813,1814,1816,1817,1820,1821,1823],{},[1443,1811,1812],{},"Does nesting change specificity?","\nThe nested selector's specificity is calculated as if ",[18,1815,40],{}," were replaced by ",[18,1818,1819],{},":is()"," around the parent selector list. For a single simple parent like ",[18,1822,1372],{},", the result matches the unnested equivalent. For a parent list mixing an ID and classes, every nested rule inherits the highest specificity in the list.",[14,1825,1826,1829,1830,1832,1833,1835],{},[1443,1827,1828],{},"Can the element being nested into be its own container?","\nIt can establish a container, but a container query never matches against the element itself. Declarations placed directly inside a nested ",[18,1831,28],{}," in the container's own rule look for a container above it. Put the container on a wrapper, or target descendants with ",[18,1834,40],{}," inside the query.",[54,1837,1839],{"id":1838},"related","Related",[1437,1841,1842,1847,1854,1861],{},[1440,1843,1844,1846],{},[43,1845,46],{"href":45}," — the parent guide.",[1440,1848,1849,1853],{},[43,1850,1852],{"href":1851},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries\u002F","Nesting and Naming Container Queries"," — nested containers, as opposed to nested CSS.",[1440,1855,1856,1860],{},[43,1857,1859],{"href":1858},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fdebugging-container-queries-in-devtools\u002F","Debugging Container Queries in DevTools"," — diagnosing a query that queries itself.",[1440,1862,1863,1867],{},[43,1864,1866],{"href":1865},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations\u002F","Starting-Style Entry Animations"," — another at-rule that nests inside element rules.",[434,1869,1870],{},"html pre.shiki code .s-5SL, html code.shiki .s-5SL{--shiki-default:#023B95;--shiki-dark:#91CBFF}html pre.shiki code .suds8, html code.shiki .suds8{--shiki-default:#0E1116;--shiki-dark:#F0F3F6}html pre.shiki code .sHUrx, html code.shiki .sHUrx{--shiki-default:#A0111F;--shiki-dark:#FF9492}html pre.shiki code .sLBg1, html code.shiki .sLBg1{--shiki-default:#66707B;--shiki-dark:#BDC4CC}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sne4z, html code.shiki .sne4z{--shiki-default:#024C1A;--shiki-dark:#72F088}html pre.shiki code .sT6z2, html code.shiki .sT6z2{--shiki-default:#032563;--shiki-dark:#ADDCFF}",{"title":67,"searchDepth":85,"depth":85,"links":1872},[1873,1874,1875,1877,1878,1879,1880,1881,1882],{"id":56,"depth":85,"text":57},{"id":315,"depth":85,"text":316},{"id":1280,"depth":85,"text":1876},"The key technique: how & and bare declarations resolve",{"id":1403,"depth":85,"text":1404},{"id":1431,"depth":85,"text":1432},{"id":1498,"depth":85,"text":1499},{"id":1750,"depth":85,"text":1751},{"id":1762,"depth":85,"text":1763},{"id":1838,"depth":85,"text":1839},"Nest @container rules inside component selectors with native CSS nesting: how & resolves, what happens to specificity, and the trap of querying yourself.","md",{"pageTitle":1886,"datePublished":1887,"dateModified":1887,"faq":1888},"Container Queries Inside CSS Nesting","2026-09-18",[1889,1892,1895,1897],{"q":1890,"a":1891},"Can @container be nested inside a CSS rule?","Yes. With native CSS nesting, conditional group rules such as @container, @media and @supports can be placed inside a style rule. Declarations directly inside the nested @container apply to the parent selector, as if written with &.",{"q":1893,"a":1894},"What does & mean inside a nested container query?","It refers to the selector of the enclosing style rule. In .card { @container (width > 30rem) { & .title { … } } }, the & stands for .card, so the rule targets .card .title when the container condition matches.",{"q":1812,"a":1896},"The nested selector's specificity is calculated as if & were replaced by :is() around the parent selector list. For a single simple parent like .card, the result matches the unnested equivalent. For a parent list mixing an ID and classes, every nested rule inherits the highest specificity in the list.",{"q":1828,"a":1898},"It can establish a container, but a container query never matches against the element itself. Declarations placed directly inside a nested @container in the container's own rule look for a container above it. Put the container on a wrapper, or target descendants with & inside the query.","\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting",{"title":5,"description":1883},"mastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting\u002Findex","lcZHQ9mG55Q6ygwwEEWOBBkRwndI9NjvgH6Se8SN8J8",[1904,1907,1910,1913,1916,1919,1922,1925,1928,1931,1934,1937,1940,1943,1946,1949,1952,1955,1958,1961,1964,1967,1970,1973,1976,1979,1982,1985,1988,1991,1994,1997,2000,2003,2006,2009,2012,2015,2018,2021,2024,2027,2030,2033,2036,2039,2042,2045,2048,2051,2054,2057,2060,2063,2066,2069,2072,2075,2078,2081,2084,2087,2090,2093,2096,2099,2102,2105,2108,2111,2114,2117,2120,2123,2126,2129,2132,2135,2138,2141,2144,2147,2150,2153,2156,2159,2162,2165,2168,2171,2174,2177,2180,2183,2185,2188,2191,2194,2197,2200,2203,2206,2209,2212,2215,2218,2221,2224,2225,2228,2231,2234,2237,2240,2243,2245,2248,2251,2254,2257,2260,2263,2266,2269,2272,2275,2278,2281,2284,2287,2290,2293,2296,2299,2302,2305,2308,2311,2314,2317,2320,2322,2325,2328,2331,2334,2337,2340,2343,2346,2349,2352,2355,2358,2361,2364,2367,2370,2373,2376,2379,2382,2385,2388,2391,2394,2397,2400,2403,2406,2409,2412,2415,2418,2421,2424,2427,2430,2433,2436,2439,2442,2445,2448,2451,2454,2457],{"path":1905,"title":1906},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fcreating-accessible-focus-indicators","Creating Accessible Focus Indicators: Building a Ring That Survives Any Background",{"path":1908,"title":1909},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fflashing-content-and-seizure-thresholds","Flashing Content and Seizure Thresholds",{"path":1911,"title":1912},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fforced-colors-mode-and-animations","Forced Colors Mode and Animations",{"path":1914,"title":1915},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations","Accessibility in CSS Animations: Patterns, Specs & Best Practices",{"path":1917,"title":1918},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fpause-controls-for-looping-animations","Pause Controls for Looping CSS Animations: Meeting WCAG 2.2.2",{"path":1920,"title":1921},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fprefers-reduced-motion-recipes","prefers-reduced-motion Recipes: A Reduction for Every Common Effect",{"path":1923,"title":1924},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Freducing-motion-preferences-in-css","Reducing Motion Preferences in CSS: How the Setting Becomes a Media Feature",{"path":1926,"title":1927},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Ftarget-size-and-pointer-accessibility","Target Size and Pointer Accessibility: Meeting 2.5.8 Without Redesigning",{"path":1929,"title":1930},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fvestibular-safe-animation-patterns","Vestibular-Safe Animation Patterns: Why Some Motion Makes People Sick",{"path":1932,"title":1933},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fwcag-motion-success-criteria","WCAG Motion Success Criteria: What Each One Actually Requires",{"path":1935,"title":1936},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fanimated-gradient-borders-with-property","Animated Gradient Borders With @property: A Spinning Highlight Without Extra Elements",{"path":1938,"title":1939},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fclip-path-reveal-animations","Clip-Path Reveal Animations: Wipes, Irises and Corners Without Extra Markup",{"path":1941,"title":1942},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations","Clip-Path & Mask Animations: Animating Visibility Instead of Position",{"path":1944,"title":1945},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fmask-image-fade-edges","Fading Edges With mask-image: Soft Boundaries That Work on Any Background",{"path":1947,"title":1948},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations\u002Fmorphing-shapes-with-clip-path-polygon","Morphing Shapes With clip-path: polygon(): Point-Matched Transitions",{"path":1950,"title":1951},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fanimating-gradients","Animating CSS Gradients: Smooth Colour Motion Without Jumps",{"path":1953,"title":1954},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fcolor-mix-hover-states","Hover and Active States With color-mix(): One Token, Every Shade",{"path":1956,"title":1957},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions","Color & Theme Transitions: Colour as Part of the Motion System",{"path":1959,"title":1960},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Flight-dark-function-for-themes","Light and Dark Themes With light-dark(): One Declaration per Colour",{"path":1962,"title":1963},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fsmooth-theme-switching-transitions","Smooth Theme Switching: Crossfades, Circular Reveals and No Flash",{"path":1965,"title":1966},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances","Container Query Hover Affordances: When Narrow Means Persistent, Not Hidden",{"path":1968,"title":1969},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion","Container-Aware Motion: Animation Sized by the Space a Component Actually Has",{"path":1971,"title":1972},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Flayout-change-animations-at-container-breakpoints","Animating Changes at Container Breakpoints",{"path":1974,"title":1975},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-driven-by-container-style-queries","Motion Driven by Container Style Queries",{"path":1977,"title":1978},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-that-scales-with-container-size","Motion That Scales with Container Size: cqi, cqb, and Derived Durations",{"path":1980,"title":1981},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fsuppressing-motion-in-small-containers","Suppressing Motion in Small Containers: Deliberately Animating Nothing",{"path":1983,"title":1984},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript","Controlling CSS Animations From JavaScript",{"path":1986,"title":1987},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api","CSS Animation vs the Web Animations API: A Decision Guide",{"path":1989,"title":1990},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwaapi-vs-css-for-interruptible-ui","Interruptible UI: CSS Transitions vs WAAPI",{"path":1992,"title":1993},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwhen-to-use-javascript-animation","When to Use JavaScript Instead of CSS for Animation",{"path":1995,"title":1996},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fanimating-custom-properties-with-at-property","Animating Custom Properties with @property: Typed Variables That Interpolate",{"path":1998,"title":1999},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fcustom-property-fallbacks-and-invalid-values","Custom Property Fallbacks and Invalid Values",{"path":2001,"title":2002},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Ffluid-spacing-tokens-driving-transition-durations","Fluid Spacing Tokens That Drive Transition Durations",{"path":2004,"title":2005},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture","CSS Custom Properties Architecture: Scalable Design Systems & Dynamic UI",{"path":2007,"title":2008},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fregistered-properties-and-type-safety","Registered Properties and Type Safety: @property as a Contract for Design Tokens",{"path":2010,"title":2011},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fscoping-custom-properties-to-components","Scoping Custom Properties to Components",{"path":2013,"title":2014},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fcss-transition-timing-functions","CSS Transition Timing Functions: ease, cubic-bezier(), steps() and linear()",{"path":2016,"title":2017},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals","CSS Transition Fundamentals: Architecture, Performance & Patterns",{"path":2019,"title":2020},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions","Interrupted and Reversing Transitions: What Happens Mid-Flight",{"path":2022,"title":2023},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations","@starting-style: Animating an Element's Very First Style Change",{"path":2025,"title":2026},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-delay-choreography","Choreographing Motion With transition-delay",{"path":2028,"title":2029},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-shorthand-and-multiple-properties","The transition Shorthand and Multiple Properties",{"path":2031,"title":2032},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete","Transitioning display with transition-behavior: allow-discrete and @starting-style",{"path":2034,"title":2035},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close","Animating \u003Cdialog> Open and Close: Both Directions, No Library",{"path":2037,"title":2038},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations","Animating ::backdrop: Fades and Blurs Behind Dialogs and Popovers",{"path":2040,"title":2041},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations","Dialog & Popover Animations: Motion for the Top Layer",{"path":2043,"title":2044},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Finterpolate-size-for-height-auto-animation","Animating to height: auto With interpolate-size and calc-size()",{"path":2046,"title":2047},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fpopover-entry-and-exit-transitions","Popover Menus That Animate From Their Anchor",{"path":2049,"title":2050},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fchoosing-animation-durations","Choosing Animation Durations: How Long Motion Should Last",{"path":2052,"title":2053},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fcubic-bezier-overshoot-and-anticipation","Overshoot and Anticipation With cubic-bezier(): Motion With Character",{"path":2055,"title":2056},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing","Entry vs Exit Easing: Different Curves for Arriving and Leaving",{"path":2058,"title":2059},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design","Easing & Motion Design: Making CSS Motion Feel Intentional",{"path":2061,"title":2062},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Flinear-easing-function-for-springs","Spring and Bounce Easing With linear(): Physical Motion Without JavaScript",{"path":2064,"title":2065},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fsteps-easing-for-sprite-animations","steps() Easing: Sprite Sheets, Typewriters and Other Frame-by-Frame Effects",{"path":2067,"title":2068},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Faccessible-css-only-tooltips","Accessible CSS-Only Tooltips and Hover Cards With  and ",{"path":2070,"title":2071},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fbutton-press-and-active-states","Button Press and  States",{"path":2073,"title":2074},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-visible-vs-focus-polyfill-alternatives"," vs :focus: Why It Replaced the Focus-Ring Polyfill",{"path":2076,"title":2077},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-within-form-patterns"," Form Patterns: Styling a Group From the Field Inside It",{"path":2079,"title":2080},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fhover-intent-delays-with-transition-delay","Hover Intent Delays With transition-delay: Menus That Don't Flicker",{"path":2082,"title":2083},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design","Hover & Focus State Design: Spec-Compliant Patterns for Modern UIs",{"path":2085,"title":2086},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fpointer-and-hover-media-queries","Pointer and Hover Media Queries: Gating Affordances by Input Capability",{"path":2088,"title":2089},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fsmooth-hover-effects-without-javascript","Smooth Hover Effects Without JavaScript: CSS-Only Patterns for Modern UI",{"path":2091,"title":2092},"\u002Fcss-only-micro-interactions-animations","CSS-Only Micro-Interactions & Animations: Architecture, Performance & Implementation",{"path":2094,"title":2095},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-composition-and-stacking","Stacking Animations With animation-composition",{"path":2097,"title":2098},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-fill-mode-explained","animation-fill-mode: What an Animation Applies Before and After It Runs",{"path":2100,"title":2101},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcontainer-query-triggered-keyframe-animations","Container-Query-Triggered Keyframe Animations: Animate Differently per Available Space",{"path":2103,"title":2104},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-accordions-and-disclosure","CSS-Only Accordions and Disclosure Widgets with details and summary",{"path":2106,"title":2107},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-loading-spinners-and-skeletons","CSS-Only Loading Spinners and Skeleton Shimmer Screens with @keyframes",{"path":2109,"title":2110},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-toggle-switches-and-checkboxes","CSS-Only Toggle Switches and Checkboxes That Keep the Native Input",{"path":2112,"title":2113},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns","Keyframe Animation Patterns: Spec-Compliant Architectures for Modern UIs",{"path":2115,"title":2116},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fmulti-step-keyframes-and-per-keyframe-easing","Multi-Step Keyframes and Per-Keyframe Easing",{"path":2118,"title":2119},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties","Staggered List Animations Using --i Index Custom Properties",{"path":2121,"title":2122},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fanimating-box-shadow-and-filters-cheaply","Animating box-shadow and Filters Cheaply",{"path":2124,"title":2125},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcontain-property-for-animation-performance","The contain Property for Animation Performance",{"path":2127,"title":2128},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcss-triggers-layout-paint-composite","Layout, Paint and Composite: What Triggers What",{"path":2130,"title":2131},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration","Performance & GPU Acceleration in CSS: A Developer’s Blueprint",{"path":2133,"title":2134},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Foptimizing-css-animations-for-60fps","Optimizing CSS Animations for 60fps: Budgeting the Frame",{"path":2136,"title":2137},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fprofiling-animations-in-devtools","Profiling CSS Animations in DevTools: Finding the Frame That Costs Too Much",{"path":2139,"title":2140},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fwill-change-and-the-compositor-thread","will-change and the Compositor Thread: Layer Promotion Without the Footguns",{"path":2142,"title":2143},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations","Scroll-Driven Animations: Binding Motion to Scroll Position in Pure CSS",{"path":2145,"title":2146},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-animation-fallbacks","Shipping Scroll-Driven Animations Without Breaking Anything",{"path":2148,"title":2149},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-parallax-effects","Scroll-Driven Parallax Effects in CSS",{"path":2151,"title":2152},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-progress-bar-without-javascript","A Reading Progress Bar Driven by scroll(root)",{"path":2154,"title":2155},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-triggered-reveal-animations","Reveal-on-Scroll with view() and animation-range",{"path":2157,"title":2158},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Ftimeline-scope-for-cross-element-animations","timeline-scope for Cross-Element Animations",{"path":2160,"title":2161},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fview-timeline-and-animation-range","View Timelines and animation-range",{"path":2163,"title":2164},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fcross-document-view-transitions","Cross-Document View Transitions",{"path":2166,"title":2167},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers","View Transitions for CSS Developers: the Pseudo-Element Tree, Snapshots, and Named Elements",{"path":2169,"title":2170},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fsame-document-view-transitions","Writing a Same-Document View Transition: the CSS You Actually Author",{"path":2172,"title":2173},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-names-shared-elements","view-transition-name and Shared Elements: Morphing a Thumbnail into a Hero",{"path":2175,"title":2176},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-types-and-classes","View Transition Types and Classes",{"path":2178,"title":2179},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-for-list-reordering","View Transitions for List Reordering",{"path":2181,"title":2182},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-with-reduced-motion","Honouring prefers-reduced-motion in View Transitions",{"path":458,"title":2184},"Modern CSS Layouts & Micro-Interactions",{"path":2186,"title":2187},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioned-tooltips","Anchor-Positioned Tooltips: Tethering, Flipping, and Getting the Semantics Right",{"path":2189,"title":2190},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioning-fallbacks","Anchor Positioning Fallbacks: A Graceful Floor for Older Browser Versions",{"path":2192,"title":2193},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-size-for-matching-widths","anchor-size(): Overlays That Match Their Trigger's Size",{"path":2195,"title":2196},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays","CSS Anchor Positioning and Overlays: Tethering Elements Without JavaScript",{"path":2198,"title":2199},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling","The popover Attribute: Top-Layer Overlays With No JavaScript",{"path":2201,"title":2202},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-light-dismiss-and-stacking","Popover Light Dismiss, Nesting and Stacking",{"path":2204,"title":2205},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fposition-area-grid-explained","position-area: The Anchor Placement Grid",{"path":2207,"title":2208},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fcontainer-query-polyfill-tradeoffs","Container Query Polyfills: What They Cost and When to Skip Them",{"path":2210,"title":2211},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ffeature-detection-with-supports","Feature Detection with @supports: Syntax, Semantics, and the Traps",{"path":2213,"title":2214},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fhandling-container-query-fallbacks-for-older-browsers","Handling Container Query Fallbacks for Older Browsers",{"path":2216,"title":2217},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks","Container Query Fallbacks: Spec-Compliant CSS Strategies for Legacy Browsers",{"path":2219,"title":2220},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fintrinsic-layout-fallbacks-without-queries","Intrinsic Layout Fallbacks: Baselines That Adapt Without Any Query",{"path":2222,"title":2223},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ftesting-fallbacks-without-old-browsers","Testing CSS Fallbacks Without an Old Browser",{"path":1899,"title":5},{"path":2226,"title":2227},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators","Container Query Range Syntax and Logic Operators",{"path":2229,"title":2230},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-units-cqi-cqb-explained","Container Query Units Explained: cqi, cqb, cqw, cqh, cqmin and cqmax",{"path":2232,"title":2233},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-type-size-vs-inline-size","Choosing container-type: inline-size, size, or normal",{"path":2235,"title":2236},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-vs-media-queries-comparison","Container vs Media Queries: Choosing the Right Reference Box",{"path":2238,"title":2239},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fdebugging-container-queries-in-devtools","Debugging Container Queries in DevTools: Why a Rule Doesn't Match",{"path":2241,"title":2242},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fhow-to-use-container-queries-in-production","How to Use Container Queries in Production Without a Rewrite",{"path":2244,"title":46},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics",{"path":2246,"title":2247},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries","Nesting and Naming Container Queries: Targeting the Right Ancestor",{"path":2249,"title":2250},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids","Responsive Grids with repeat(auto-fit, minmax())",{"path":2252,"title":2253},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fbuilding-a-dashboard-with-subgrid","Building a Responsive Dashboard Where Cards Align with Subgrid",{"path":2255,"title":2256},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-auto-flow-dense-packing","grid-auto-flow: dense for Packed Layouts",{"path":2258,"title":2259},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-template-areas-responsive-layouts","Responsive Layouts With grid-template-areas: Rearranging Regions by Name",{"path":2261,"title":2262},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fholy-grail-layout-with-grid","The Holy-Grail Layout with CSS Grid and Container Queries",{"path":2264,"title":2265},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts","CSS Grid and Subgrid Layouts for Responsive Interfaces",{"path":2267,"title":2268},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fmasonry-style-layouts-with-grid","Masonry-Style Layouts With the CSS That Ships Today",{"path":2270,"title":2271},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Foverlapping-elements-with-grid-stacking","Overlapping Elements With Grid Stacking: Layers Without position: absolute",{"path":2273,"title":2274},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fsubgrid-vs-nested-grid","Subgrid vs an Independently Nested Grid",{"path":2276,"title":2277},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fcentering-in-css-every-method","Centering in CSS: Every Modern Method and When Each One Breaks",{"path":2279,"title":2280},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-basis-vs-width","flex-basis vs width: Which Size a Flex Item Actually Starts From",{"path":2282,"title":2283},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-grow-and-flex-shrink-explained","flex-grow and flex-shrink Explained",{"path":2285,"title":2286},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-wrap-intrinsic-responsive-rows","Breakpoint-Free Responsive Rows With flex-wrap and flex-basis",{"path":2288,"title":2289},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing","Flexbox gap vs Margins: Spacing Items Without Edge Hacks",{"path":2291,"title":2292},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns","Flexbox Layout Patterns: One-Dimensional Layout for Real Components",{"path":2294,"title":2295},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fsticky-footer-with-flexbox-and-grid","Sticky Footer With Flexbox or Grid: Pinning the Footer on Short Pages",{"path":2297,"title":2298},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fclamp-vs-media-query-typography","clamp() Fluid Type vs Media-Query Step Typography: Tradeoffs and Anatomy",{"path":2300,"title":2301},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fdebugging-clamp-values","Debugging clamp(): Values That Are Ignored, Stuck or Never Fluid",{"path":2303,"title":2304},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-line-height-and-measure","Fluid Line Height and Measure: Keeping Text Readable as It Scales",{"path":2306,"title":2307},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-space-scale-with-clamp","Building a Fluid Spacing Scale with clamp() and Container Units",{"path":2309,"title":2310},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-type-accessibility-and-zoom","Fluid Type, Accessibility and Zoom: The vw-Only Trap",{"path":2312,"title":2313},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-typography-without-javascript","Fluid Typography Without JavaScript: A Precision CSS Reference",{"path":2315,"title":2316},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp","Fluid Typography with clamp(): A Practical Guide for Modern CSS",{"path":2318,"title":2319},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ftext-wrap-balance-and-pretty","text-wrap: balance and pretty: Better Line Breaks Without Manual Breaks",{"path":2321,"title":51},"\u002Fmastering-container-queries-responsive-layouts",{"path":2323,"title":2324},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media","Using aspect-ratio for Responsive Media and Preventing Layout Shift",{"path":2326,"title":2327},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fcontent-visibility-and-contain-intrinsic-size","content-visibility and contain-intrinsic-size: Rendering Only What Is Near the Screen",{"path":2329,"title":2330},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques","Intrinsic Sizing Techniques: Modern CSS Layouts for Responsive UI",{"path":2332,"title":2333},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Flayout-widths-with-min-max-clamp","Layout Widths With min(), max() and clamp(): Sizing Without Breakpoints",{"path":2335,"title":2336},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained","min-content, max-content, and fit-content() Explained",{"path":2338,"title":2339},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position","object-fit and object-position: Images That Fit Any Box",{"path":2341,"title":2342},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fpreventing-flex-and-grid-overflow","The min-width: auto Trap in Flex and Grid Layouts",{"path":2344,"title":2345},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens","Cascade Layers for Reset and Design Tokens",{"path":2347,"title":2348},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-vs-specificity-hacks","Cascade Layers vs Specificity Hacks: Ordering Instead of Escalating",{"path":2350,"title":2351},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcss-scope-for-component-styles","@scope for Component Styles: Short Selectors That Cannot Leak",{"path":2353,"title":2354},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies","Modern CSS Reset Strategies: A Spec-Compliant Foundation",{"path":2356,"title":2357},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Frevert-layer-and-revert-keywords","initial, inherit, unset, revert and revert-layer: Undoing Styles Correctly",{"path":2359,"title":2360},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fwriting-a-minimal-modern-reset","Writing a Minimal Modern CSS Reset: Every Line Justified",{"path":2362,"title":2363},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fcontent-aware-card-layouts-with-has","Content-Aware Card Layouts With :has(): One Component, Many Shapes",{"path":2365,"title":2366},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fempty-and-loading-states-with-has","Empty and Loading States With ()",{"path":2368,"title":2369},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fform-validation-layouts-with-has","Form Validation Layouts With :has(): Styling Groups From Field State",{"path":2371,"title":2372},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-selector-performance",":has() Selector Performance: What Is Cheap, What Is Not, and How to Measure",{"path":2374,"title":2375},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-vs-container-style-queries",":has() vs Container Style Queries: Discovered State and Published State",{"path":2377,"title":2378},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has","Parent-Aware Layouts With :has(): Letting Containers React to Their Contents",{"path":2380,"title":2381},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has","Quantity Queries With :has(): Layouts That Respond to How Many Items There Are",{"path":2383,"title":2384},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fbuilding-responsive-cards-with-container-queries","Building Responsive Cards with Container Queries: A Production-Ready Guide",{"path":2386,"title":2387},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-data-tables","Container Query Data Tables: Reflowing Tables to Cards",{"path":2389,"title":2390},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-sidebar-layouts","Container Query Sidebar Layouts That Travel Between Contexts",{"path":2392,"title":2393},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns","Responsive Component Patterns: Architecture & Implementation",{"path":2395,"title":2396},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-forms-with-container-queries","Responsive Forms with Container Queries: Reflow Without Losing the Wiring",{"path":2398,"title":2399},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-hero-sections-with-container-queries","Responsive Hero Sections With Container Queries",{"path":2401,"title":2402},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries","Responsive Navigation Without Media Queries Using Container Queries",{"path":2404,"title":2405},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-pricing-tables","Responsive Pricing Tables: Aligned Features, a Clear Recommendation, Any Width",{"path":2407,"title":2408},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Ftabs-that-become-accordions","Tabs That Become an Accordion: One Component, Two Layouts",{"path":2410,"title":2411},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fcss-only-carousel-with-scroll-snap","A CSS-Only Carousel With Scroll Snap",{"path":2413,"title":2414},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fhorizontal-scrolling-card-rows","Horizontal Scrolling Card Rows: Swipeable Lists That Stay in Their Lane",{"path":2416,"title":2417},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts","Scroll Snap & Overflow Layouts: Designing Components That Scroll on Purpose",{"path":2419,"title":2420},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Foverscroll-behavior-for-nested-scrolling","overscroll-behavior: Taming Nested Scrolling, Pull-to-Refresh and Back-Swipe",{"path":2422,"title":2423},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fscroll-margin-and-scroll-padding-for-sticky-headers","scroll-margin and scroll-padding: Keeping Targets Clear of Sticky Headers",{"path":2425,"title":2426},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcombining-size-and-style-queries","Combining Size and Style Container Queries",{"path":2428,"title":2429},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcontainer-style-query-theming","Container Style Query Theming: One Token Instead of a Variant Class Matrix",{"path":2431,"title":2432},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state","Style Queries and Container State: Token-Driven Component Variants",{"path":2434,"title":2435},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-queries-with-custom-properties","Style Queries With Custom Properties: Declaring, Inheriting, and Matching Tokens",{"path":2437,"title":2438},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-component-variants","Component Variants With Style Queries: One Token, Many Looks",{"path":2440,"title":2441},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-fallbacks-and-support","Style Query Fallbacks and Support: Designing for Older Browser Versions",{"path":2443,"title":2444},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fdvh-svh-lvh-mobile-viewport-units","dvh, svh and lvh: Choosing the Right Mobile Viewport Unit",{"path":2446,"title":2447},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Ffull-bleed-sections-in-constrained-layouts","Full-Bleed Sections in a Constrained Layout: Breaking Out Without Breaking the Page",{"path":2449,"title":2450},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout","Viewport Units & Mobile Layout: Designing for the Screen You Actually Get",{"path":2452,"title":2453},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fsafe-area-insets-for-notched-screens","Safe Area Insets: Designing Around Notches, Corners and Home Indicators",{"path":2455,"title":2456},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fviewport-units-vs-container-units","Viewport Units vs Container Units: Choosing the Right Reference Box",{"path":2458,"title":2459},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fvirtual-keyboard-and-interactive-widget","Layouts That Survive the Virtual Keyboard",{"title":2461,"caption":2462,"height":2463,"resizable":120,"html":2464,"css":2465},"Card whose container queries are nested in each rule","Drag the frame: above 32rem the card goes side by side, the title grows and the media turns square; under 20rem the author is hidden.",280,"\n\u003Cdiv class=\"card-slot\">\n  \u003Carticle class=\"card\">\n    \u003Cdiv class=\"card__media\" role=\"img\" aria-label=\"Abstract illustration\">\u003C\u002Fdiv>\n    \u003Cdiv>\n      \u003Ch3 class=\"card__title\">Designing for containers\u003C\u002Fh3>\n      \u003Cp class=\"card__meta\">\u003Cspan class=\"card__author\">Mira Chen\u003C\u002Fspan> · \u003Ctime>12 Sep\u003C\u002Ftime>\u003C\u002Fp>\n    \u003C\u002Fdiv>\n  \u003C\u002Farticle>\n\u003C\u002Fdiv>","\n.card-slot { container: card \u002F inline-size; }\n.card {\n  display: grid;\n  gap: 0.75rem;\n  padding: 1rem;\n  border: 1px solid var(--demo-border);\n  border-radius: 12px;\n  @container card (width > 32rem) { grid-template-columns: 10rem 1fr; padding: 1.5rem; }\n}\n.card__media {\n  aspect-ratio: 16 \u002F 9;\n  max-height: 7rem;\n  border-radius: 8px;\n  background: linear-gradient(135deg, #c7d2fe, #818cf8);\n  @container card (width > 32rem) { aspect-ratio: 1; max-height: none; }\n}\n.card__title { margin: 0; font-size: 1.1rem; @container card (width > 32rem) { font-size: 1.35rem; } }\n.card__meta {\n  margin: 0;\n  color: var(--demo-muted);\n  font-size: 0.85rem;\n  & time { font-variant-numeric: tabular-nums; }\n  @container card (width \u003C 20rem) { & .card__author { display: none; } }\n}",1789717748056]