[{"data":1,"prerenderedAt":2300},["ShallowReactive",2],{"page-\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has\u002F":3,"content-all-pages":1736,"live-demo:has-quantity-gallery":2294},{"id":4,"title":5,"body":6,"description":1717,"extension":1718,"meta":1719,"navigation":404,"path":1732,"seo":1733,"stem":1734,"__hash__":1735},"content\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has\u002Findex.md","Quantity Queries With :has(): Layouts That Respond to How Many Items There Are",{"type":7,"value":8,"toc":1706},"minimark",[9,19,40,45,52,74,77,81,91,180,187,209,213,216,220,1010,1017,1021,1039,1117,1135,1139,1157,1375,1391,1395,1403,1560,1568,1572,1594,1598,1609,1618,1641,1656,1660,1703],[10,11,13,14,18],"h1",{"id":12},"quantity-queries-with-has-layouts-that-respond-to-how-many-items-there-are","Quantity Queries With ",[15,16,17],"code",{},":has()",": Layouts That Respond to How Many Items There Are",[20,21,22,23,27,28,34,35,39],"p",{},"A feature row looks right with three items and wrong with five. A navigation bar fits four links and needs to become a menu at seven. A photo gallery should show a single image full-width, two side by side, and three or more in a grid. None of these decisions depend on the viewport or even on the container's width; they depend on a ",[24,25,26],"em",{},"count",". This page shows how to express that count in CSS by combining ",[29,30,32],"a",{"href":31},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002F",[15,33,17],{}," with the structural pseudo-classes, so the container itself changes layout when it gains or loses children. It sits within the ",[29,36,38],{"href":37},"\u002Fmastering-container-queries-responsive-layouts\u002F","Mastering Container Queries & Responsive Layouts"," guide.",[41,42,44],"h2",{"id":43},"why-count-in-css-rather-than-in-a-template","Why count in CSS rather than in a template",[20,46,47,48,51],{},"The traditional answer is a class set by the template: ",[15,49,50],{},"gallery--count-3",". It works until the content changes on the client — a filter hides items, a user deletes a card, a CMS editor adds one — and then the class is stale until something re-renders. A selector-based count cannot go stale, because the browser re-evaluates it on every DOM mutation. It also keeps the layout logic in the stylesheet, where the people changing layouts actually look.",[20,53,54,55,58,59,62,63,66,67,70,71,73],{},"Quantity queries have existed for a decade in a limited form. The old technique, ",[15,56,57],{},"li:nth-last-child(n+4), li:nth-last-child(n+4) ~ li",", selects every item in a list of four or more, which lets you restyle the ",[24,60,61],{},"items",". What it cannot do is restyle the ",[24,64,65],{},"list",": change its ",[15,68,69],{},"grid-template-columns",", switch it from flex to grid, or alter its gap. Before ",[15,72,17],{},", CSS had no way for a parent to react to anything about its children. Now it does, and the count becomes a first-class layout input.",[20,75,76],{},"The accessibility cost is nil, since nothing about the DOM or reading order changes. What changes is only how the same content is arranged, and the arrangement tracks the content automatically.",[41,78,80],{"id":79},"the-three-building-blocks","The three building blocks",[20,82,83,84,87,88,90],{},"Every quantity query is built from one fact: ",[15,85,86],{},":nth-child(N)"," matches only if at least N siblings exist. Wrapped in ",[15,89,17],{},", that becomes a test on the parent.",[92,93,99,100,99,104,99,108,99,116,99,126,99,133,99,138,99,144,99,147,99,151,99,155,99,159,99,163,99,167,99,171,99,175],"svg",{"viewBox":94,"role":95,"ariaLabel":96,"xmlns":97,"style":98},"0 0 720 320","img","Three selector recipes for at least N, at most N and exactly N children, with the counts each one matches","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg","width:100%;height:auto;max-width:720px;margin:2rem 0","\n  ",[101,102,103],"title",{},"At least, at most and exactly N",[105,106,107],"desc",{},"At least three uses has nth-child three. At most three uses not has nth-child four. Exactly three combines both. Each row lists the child counts that match.",[109,110,115],"text",{"textAnchor":111,"x":112,"y":113,"style":114},"middle","360","26","text-anchor:middle;fill:currentColor;font:700 17px sans-serif","Counting children with one pseudo-class",[117,118],"rect",{"x":119,"y":120,"width":121,"height":122,"rx":123,"fill":124,"opacity":125},"30","46","660","64","8","#7aa2ff","0.16",[109,127,132],{"textAnchor":128,"x":129,"y":130,"style":131},"start","50","72","text-anchor:start;fill:currentColor;font:600 13px sans-serif","at least 3",[109,134,137],{"textAnchor":128,"x":129,"y":135,"style":136},"96","text-anchor:start;fill:currentColor;font:12px ui-monospace,monospace",".list:has(> :nth-child(3))",[109,139,143],{"textAnchor":111,"x":140,"y":141,"style":142},"620","84","text-anchor:middle;fill:currentColor;font:12px sans-serif","3, 4, 5 …",[117,145],{"x":119,"y":146,"width":121,"height":122,"rx":123,"fill":124,"opacity":125},"122",[109,148,150],{"textAnchor":128,"x":129,"y":149,"style":131},"148","at most 3",[109,152,154],{"textAnchor":128,"x":129,"y":153,"style":136},"172",".list:not(:has(> :nth-child(4)))",[109,156,158],{"textAnchor":111,"x":140,"y":157,"style":142},"160","0, 1, 2, 3",[117,160],{"x":119,"y":161,"width":121,"height":122,"rx":123,"fill":124,"opacity":162},"198","0.32",[109,164,166],{"textAnchor":128,"x":129,"y":165,"style":131},"224","exactly 3",[109,168,170],{"textAnchor":128,"x":129,"y":169,"style":136},"248",".list:has(> :nth-child(3)):not(:has(> :nth-child(4)))",[109,172,174],{"textAnchor":111,"x":140,"y":173,"style":142},"236","3 only",[109,176,179],{"textAnchor":111,"x":112,"y":177,"style":178},"296","text-anchor:middle;fill:currentColor;font:12px sans-serif;opacity:0.75","The child combinator matters: without it, grandchildren are counted too.",[20,181,182,183,186],{},"An alternative for \"exactly N\" is ",[15,184,185],{},".list:has(> :nth-child(3):last-child)"," — the third child is also the last, so there are exactly three. It is shorter and reads nicely, but the two-part form generalises to ranges (\"between three and five\") by changing the second number, which makes it the better habit.",[20,188,189,190,193,194,196,197,200,201,204,205,208],{},"The child combinator ",[15,191,192],{},">"," inside ",[15,195,17],{}," is not optional decoration. Without it, ",[15,198,199],{},":has(:nth-child(3))"," matches if ",[24,202,203],{},"any descendant"," is the third child of ",[24,206,207],{},"its"," parent, so a card containing a three-item list inside it would make the outer grid think it has three cards.",[41,210,212],{"id":211},"the-complete-implementation","The complete implementation",[20,214,215],{},"The gallery below changes its entire layout by count: one image spans full width with a wide ratio, two sit side by side, three form a feature layout with one large tile, and four or more become a regular grid. Add or remove figures in the markup and the layout follows. The demo renders the same stylesheet four times, with one, two, three and five figures, so every branch is visible at once; drag it narrower to watch the four-plus grid drop columns.",[217,218],"live-demo",{"name":219},"has-quantity-gallery",[221,222,227],"pre",{"className":223,"code":224,"language":225,"meta":226,"style":226},"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>Quantity query gallery\u003C\u002Ftitle>\n\u003Cstyle>\n  body { font: 15px\u002F1.5 system-ui, sans-serif; margin: 1.5rem; }\n\n  .gallery {\n    display: grid;\n    gap: 0.5rem;\n    \u002F* Default for 1 item: a single full-width tile. *\u002F\n    grid-template-columns: 1fr;\n  }\n\n  .gallery > figure {\n    margin: 0;\n    min-height: 8rem;\n    border-radius: 8px;\n    background: linear-gradient(135deg, #bfdbfe, #818cf8);\n    display: grid;\n    place-items: end start;\n    padding: 0.5rem;\n    color: #0f172a;\n  }\n\n  \u002F* Exactly one item: wide cinematic ratio. *\u002F\n  .gallery:not(:has(> :nth-child(2))) > figure {\n    aspect-ratio: 21 \u002F 9;\n  }\n\n  \u002F* At least two: two equal columns. *\u002F\n  .gallery:has(> :nth-child(2)) {\n    grid-template-columns: repeat(2, 1fr);\n  }\n\n  \u002F* Exactly three: the first tile becomes a tall feature on the left. *\u002F\n  .gallery:has(> :nth-child(3)):not(:has(> :nth-child(4))) > :first-child {\n    grid-row: span 2;\n  }\n\n  \u002F* Four or more: a regular responsive grid, and no spanning. *\u002F\n  .gallery:has(> :nth-child(4)) {\n    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));\n  }\n\u003C\u002Fstyle>\n\u003C\u002Fhead>\n\u003Cbody>\n  \u003Cdiv class=\"gallery\">\n    \u003Cfigure>One\u003C\u002Ffigure>\n    \u003Cfigure>Two\u003C\u002Ffigure>\n    \u003Cfigure>Three\u003C\u002Ffigure>\n  \u003C\u002Fdiv>\n\u003C\u002Fbody>\n\u003C\u002Fhtml>\n","html","",[15,228,229,249,269,279,297,322,336,346,399,406,415,429,444,451,467,473,478,491,504,518,532,565,576,592,606,619,624,629,635,667,686,691,696,702,721,743,748,753,759,805,818,823,828,834,851,885,890,900,909,919,938,954,968,982,992,1001],{"__ignoreMap":226},[230,231,234,238,242,246],"span",{"class":232,"line":233},"line",1,[230,235,237],{"class":236},"suds8","\u003C!",[230,239,241],{"class":240},"sne4z","doctype",[230,243,245],{"class":244},"s-5SL"," html",[230,247,248],{"class":236},">\n",[230,250,252,255,257,260,263,267],{"class":232,"line":251},2,[230,253,254],{"class":236},"\u003C",[230,256,225],{"class":240},[230,258,259],{"class":244}," lang",[230,261,262],{"class":236},"=",[230,264,266],{"class":265},"sT6z2","\"en\"",[230,268,248],{"class":236},[230,270,272,274,277],{"class":232,"line":271},3,[230,273,254],{"class":236},[230,275,276],{"class":240},"head",[230,278,248],{"class":236},[230,280,282,284,287,290,292,295],{"class":232,"line":281},4,[230,283,254],{"class":236},[230,285,286],{"class":240},"meta",[230,288,289],{"class":244}," charset",[230,291,262],{"class":236},[230,293,294],{"class":265},"\"utf-8\"",[230,296,248],{"class":236},[230,298,300,302,304,307,309,312,315,317,320],{"class":232,"line":299},5,[230,301,254],{"class":236},[230,303,286],{"class":240},[230,305,306],{"class":244}," name",[230,308,262],{"class":236},[230,310,311],{"class":265},"\"viewport\"",[230,313,314],{"class":244}," content",[230,316,262],{"class":236},[230,318,319],{"class":265},"\"width=device-width, initial-scale=1\"",[230,321,248],{"class":236},[230,323,325,327,329,332,334],{"class":232,"line":324},6,[230,326,254],{"class":236},[230,328,101],{"class":240},[230,330,331],{"class":236},">Quantity query gallery\u003C\u002F",[230,333,101],{"class":240},[230,335,248],{"class":236},[230,337,339,341,344],{"class":232,"line":338},7,[230,340,254],{"class":236},[230,342,343],{"class":240},"style",[230,345,248],{"class":236},[230,347,349,352,355,358,361,364,368,371,374,377,380,383,386,389,391,393,396],{"class":232,"line":348},8,[230,350,351],{"class":240},"  body",[230,353,354],{"class":236}," { ",[230,356,357],{"class":244},"font",[230,359,360],{"class":236},": ",[230,362,363],{"class":244},"15",[230,365,367],{"class":366},"sHUrx","px",[230,369,370],{"class":236},"\u002F",[230,372,373],{"class":244},"1.5",[230,375,376],{"class":244}," system-ui",[230,378,379],{"class":236},", ",[230,381,382],{"class":244},"sans-serif",[230,384,385],{"class":236},"; ",[230,387,388],{"class":244},"margin",[230,390,360],{"class":236},[230,392,373],{"class":244},[230,394,395],{"class":366},"rem",[230,397,398],{"class":236},"; }\n",[230,400,402],{"class":232,"line":401},9,[230,403,405],{"emptyLinePlaceholder":404},true,"\n",[230,407,409,412],{"class":232,"line":408},10,[230,410,411],{"class":244},"  .gallery",[230,413,414],{"class":236}," {\n",[230,416,418,421,423,426],{"class":232,"line":417},11,[230,419,420],{"class":244},"    display",[230,422,360],{"class":236},[230,424,425],{"class":244},"grid",[230,427,428],{"class":236},";\n",[230,430,432,435,437,440,442],{"class":232,"line":431},12,[230,433,434],{"class":244},"    gap",[230,436,360],{"class":236},[230,438,439],{"class":244},"0.5",[230,441,395],{"class":366},[230,443,428],{"class":236},[230,445,447],{"class":232,"line":446},13,[230,448,450],{"class":449},"sLBg1","    \u002F* Default for 1 item: a single full-width tile. *\u002F\n",[230,452,454,457,459,462,465],{"class":232,"line":453},14,[230,455,456],{"class":244},"    grid-template-columns",[230,458,360],{"class":236},[230,460,461],{"class":244},"1",[230,463,464],{"class":366},"fr",[230,466,428],{"class":236},[230,468,470],{"class":232,"line":469},15,[230,471,472],{"class":236},"  }\n",[230,474,476],{"class":232,"line":475},16,[230,477,405],{"emptyLinePlaceholder":404},[230,479,481,483,486,489],{"class":232,"line":480},17,[230,482,411],{"class":244},[230,484,485],{"class":366}," >",[230,487,488],{"class":240}," figure",[230,490,414],{"class":236},[230,492,494,497,499,502],{"class":232,"line":493},18,[230,495,496],{"class":244},"    margin",[230,498,360],{"class":236},[230,500,501],{"class":244},"0",[230,503,428],{"class":236},[230,505,507,510,512,514,516],{"class":232,"line":506},19,[230,508,509],{"class":244},"    min-height",[230,511,360],{"class":236},[230,513,123],{"class":244},[230,515,395],{"class":366},[230,517,428],{"class":236},[230,519,521,524,526,528,530],{"class":232,"line":520},20,[230,522,523],{"class":244},"    border-radius",[230,525,360],{"class":236},[230,527,123],{"class":244},[230,529,367],{"class":366},[230,531,428],{"class":236},[230,533,535,538,540,543,546,549,552,554,557,559,562],{"class":232,"line":534},21,[230,536,537],{"class":244},"    background",[230,539,360],{"class":236},[230,541,542],{"class":244},"linear-gradient",[230,544,545],{"class":236},"(",[230,547,548],{"class":244},"135",[230,550,551],{"class":366},"deg",[230,553,379],{"class":236},[230,555,556],{"class":244},"#bfdbfe",[230,558,379],{"class":236},[230,560,561],{"class":244},"#818cf8",[230,563,564],{"class":236},");\n",[230,566,568,570,572,574],{"class":232,"line":567},22,[230,569,420],{"class":244},[230,571,360],{"class":236},[230,573,425],{"class":244},[230,575,428],{"class":236},[230,577,579,582,584,587,590],{"class":232,"line":578},23,[230,580,581],{"class":244},"    place-items",[230,583,360],{"class":236},[230,585,586],{"class":244},"end",[230,588,589],{"class":244}," start",[230,591,428],{"class":236},[230,593,595,598,600,602,604],{"class":232,"line":594},24,[230,596,597],{"class":244},"    padding",[230,599,360],{"class":236},[230,601,439],{"class":244},[230,603,395],{"class":366},[230,605,428],{"class":236},[230,607,609,612,614,617],{"class":232,"line":608},25,[230,610,611],{"class":244},"    color",[230,613,360],{"class":236},[230,615,616],{"class":244},"#0f172a",[230,618,428],{"class":236},[230,620,622],{"class":232,"line":621},26,[230,623,472],{"class":236},[230,625,627],{"class":232,"line":626},27,[230,628,405],{"emptyLinePlaceholder":404},[230,630,632],{"class":232,"line":631},28,[230,633,634],{"class":449},"  \u002F* Exactly one item: wide cinematic ratio. *\u002F\n",[230,636,638,641,643,646,648,650,653,655,658,661,663,665],{"class":232,"line":637},29,[230,639,640],{"class":244},"  .gallery:not",[230,642,545],{"class":236},[230,644,645],{"class":244},":has",[230,647,545],{"class":236},[230,649,192],{"class":366},[230,651,652],{"class":244}," :nth-child",[230,654,545],{"class":236},[230,656,657],{"class":244},"2",[230,659,660],{"class":236},"))) ",[230,662,192],{"class":366},[230,664,488],{"class":240},[230,666,414],{"class":236},[230,668,670,673,675,678,681,684],{"class":232,"line":669},30,[230,671,672],{"class":244},"    aspect-ratio",[230,674,360],{"class":236},[230,676,677],{"class":244},"21",[230,679,680],{"class":236}," \u002F ",[230,682,683],{"class":244},"9",[230,685,428],{"class":236},[230,687,689],{"class":232,"line":688},31,[230,690,472],{"class":236},[230,692,694],{"class":232,"line":693},32,[230,695,405],{"emptyLinePlaceholder":404},[230,697,699],{"class":232,"line":698},33,[230,700,701],{"class":449},"  \u002F* At least two: two equal columns. *\u002F\n",[230,703,705,708,710,712,714,716,718],{"class":232,"line":704},34,[230,706,707],{"class":244},"  .gallery:has",[230,709,545],{"class":236},[230,711,192],{"class":366},[230,713,652],{"class":244},[230,715,545],{"class":236},[230,717,657],{"class":244},[230,719,720],{"class":236},")) {\n",[230,722,724,726,728,731,733,735,737,739,741],{"class":232,"line":723},35,[230,725,456],{"class":244},[230,727,360],{"class":236},[230,729,730],{"class":244},"repeat",[230,732,545],{"class":236},[230,734,657],{"class":244},[230,736,379],{"class":236},[230,738,461],{"class":244},[230,740,464],{"class":366},[230,742,564],{"class":236},[230,744,746],{"class":232,"line":745},36,[230,747,472],{"class":236},[230,749,751],{"class":232,"line":750},37,[230,752,405],{"emptyLinePlaceholder":404},[230,754,756],{"class":232,"line":755},38,[230,757,758],{"class":449},"  \u002F* Exactly three: the first tile becomes a tall feature on the left. *\u002F\n",[230,760,762,764,766,768,770,772,775,778,781,783,785,787,789,791,793,796,798,800,803],{"class":232,"line":761},39,[230,763,707],{"class":244},[230,765,545],{"class":236},[230,767,192],{"class":366},[230,769,652],{"class":244},[230,771,545],{"class":236},[230,773,774],{"class":244},"3",[230,776,777],{"class":236},"))",[230,779,780],{"class":244},":not",[230,782,545],{"class":236},[230,784,645],{"class":244},[230,786,545],{"class":236},[230,788,192],{"class":366},[230,790,652],{"class":244},[230,792,545],{"class":236},[230,794,795],{"class":244},"4",[230,797,660],{"class":236},[230,799,192],{"class":366},[230,801,802],{"class":244}," :first-child",[230,804,414],{"class":236},[230,806,808,811,814,816],{"class":232,"line":807},40,[230,809,810],{"class":244},"    grid-row",[230,812,813],{"class":236},": span ",[230,815,657],{"class":244},[230,817,428],{"class":236},[230,819,821],{"class":232,"line":820},41,[230,822,472],{"class":236},[230,824,826],{"class":232,"line":825},42,[230,827,405],{"emptyLinePlaceholder":404},[230,829,831],{"class":232,"line":830},43,[230,832,833],{"class":449},"  \u002F* Four or more: a regular responsive grid, and no spanning. *\u002F\n",[230,835,837,839,841,843,845,847,849],{"class":232,"line":836},44,[230,838,707],{"class":244},[230,840,545],{"class":236},[230,842,192],{"class":366},[230,844,652],{"class":244},[230,846,545],{"class":236},[230,848,795],{"class":244},[230,850,720],{"class":236},[230,852,854,856,858,860,862,865,867,870,872,874,876,878,880,882],{"class":232,"line":853},45,[230,855,456],{"class":244},[230,857,360],{"class":236},[230,859,730],{"class":244},[230,861,545],{"class":236},[230,863,864],{"class":244},"auto-fill",[230,866,379],{"class":236},[230,868,869],{"class":244},"minmax",[230,871,545],{"class":236},[230,873,683],{"class":244},[230,875,395],{"class":366},[230,877,379],{"class":236},[230,879,461],{"class":244},[230,881,464],{"class":366},[230,883,884],{"class":236},"));\n",[230,886,888],{"class":232,"line":887},46,[230,889,472],{"class":236},[230,891,893,896,898],{"class":232,"line":892},47,[230,894,895],{"class":236},"\u003C\u002F",[230,897,343],{"class":240},[230,899,248],{"class":236},[230,901,903,905,907],{"class":232,"line":902},48,[230,904,895],{"class":236},[230,906,276],{"class":240},[230,908,248],{"class":236},[230,910,912,914,917],{"class":232,"line":911},49,[230,913,254],{"class":236},[230,915,916],{"class":240},"body",[230,918,248],{"class":236},[230,920,922,925,928,931,933,936],{"class":232,"line":921},50,[230,923,924],{"class":236},"  \u003C",[230,926,927],{"class":240},"div",[230,929,930],{"class":244}," class",[230,932,262],{"class":236},[230,934,935],{"class":265},"\"gallery\"",[230,937,248],{"class":236},[230,939,941,944,947,950,952],{"class":232,"line":940},51,[230,942,943],{"class":236},"    \u003C",[230,945,946],{"class":240},"figure",[230,948,949],{"class":236},">One\u003C\u002F",[230,951,946],{"class":240},[230,953,248],{"class":236},[230,955,957,959,961,964,966],{"class":232,"line":956},52,[230,958,943],{"class":236},[230,960,946],{"class":240},[230,962,963],{"class":236},">Two\u003C\u002F",[230,965,946],{"class":240},[230,967,248],{"class":236},[230,969,971,973,975,978,980],{"class":232,"line":970},53,[230,972,943],{"class":236},[230,974,946],{"class":240},[230,976,977],{"class":236},">Three\u003C\u002F",[230,979,946],{"class":240},[230,981,248],{"class":236},[230,983,985,988,990],{"class":232,"line":984},54,[230,986,987],{"class":236},"  \u003C\u002F",[230,989,927],{"class":240},[230,991,248],{"class":236},[230,993,995,997,999],{"class":232,"line":994},55,[230,996,895],{"class":236},[230,998,916],{"class":240},[230,1000,248],{"class":236},[230,1002,1004,1006,1008],{"class":232,"line":1003},56,[230,1005,895],{"class":236},[230,1007,225],{"class":240},[230,1009,248],{"class":236},[20,1011,1012,1013,1016],{},"The rules are ordered from fewest to most items, and each later rule overrides the earlier ones where they overlap. At four items, both \"at least two\" and \"at least four\" match; the later ",[15,1014,1015],{},"repeat(auto-fill, …)"," wins by source order because the specificities are equal. The \"exactly three\" rule is written as a closed range so it cannot leak into the four-plus layout and span a tile in the regular grid.",[41,1018,1020],{"id":1019},"the-key-technique-the-parent-is-the-subject","The key technique: the parent is the subject",[20,1022,1023,1024,1027,1028,1031,1032,1035,1036,1038],{},"The reason this works is subtle and worth stating precisely. In ",[15,1025,1026],{},".gallery:has(> :nth-child(3))",", the ",[24,1029,1030],{},"subject"," of the selector — the element that receives the declarations — is ",[15,1033,1034],{},".gallery",". Everything inside the parentheses is a condition evaluated relative to it. That inversion is what ",[15,1037,17],{}," adds to CSS: the ability to style an element based on what it contains.",[92,1040,99,1043,99,1046,99,1049,99,1052,99,1058,99,1067,99,1071,99,1077,99,1080,99,1083,99,1086,99,1090,99,1094,99,1098,99,1102,99,1107,99,1110,99,1112,99,1114],{"viewBox":1041,"role":95,"ariaLabel":1042,"xmlns":97,"style":98},"0 0 720 300","Comparison of the old nth-last-child technique that styles every item and the has technique that styles the container",[101,1044,1045],{},"Styling the items versus styling the container",[105,1047,1048],{},"Left, the legacy nth-last-child selector matches each of four items but cannot touch the list. Right, the has selector matches the list itself, so its grid template can change.",[109,1050,1051],{"textAnchor":111,"x":112,"y":113,"style":114},"Which element receives the declarations",[109,1053,1057],{"textAnchor":111,"x":1054,"y":1055,"style":1056},"190","56","text-anchor:middle;fill:currentColor;font:600 12px ui-monospace,monospace","li:nth-last-child(n+4) ~ li",[117,1059],{"x":129,"y":1060,"width":1061,"height":157,"rx":123,"fill":1062,"stroke":1063,"strokeWidth":373,"strokeDashArray":1064,"opacity":1066},"70","280","none","currentColor",[1065,795],"5","0.6",[109,1068,1070],{"textAnchor":111,"x":1054,"y":1069,"style":142},"92","ul: unreachable",[117,1072],{"x":1060,"y":1073,"width":1074,"height":1075,"rx":795,"fill":124,"opacity":1076},"104","240","24","0.4",[117,1078],{"x":1060,"y":1079,"width":1074,"height":1075,"rx":795,"fill":124,"opacity":1076},"134",[117,1081],{"x":1060,"y":1082,"width":1074,"height":1075,"rx":795,"fill":124,"opacity":1076},"164",[117,1084],{"x":1060,"y":1085,"width":1074,"height":1075,"rx":795,"fill":124,"opacity":1076},"194",[109,1087,1089],{"textAnchor":111,"x":1054,"y":1088,"style":142},"256","each item styled, list untouched",[109,1091,1093],{"textAnchor":111,"x":1092,"y":1055,"style":1056},"530","ul:has(> :nth-child(4))",[117,1095],{"x":1096,"y":1060,"width":1061,"height":157,"rx":123,"fill":124,"opacity":1097},"390","0.28",[109,1099,1101],{"textAnchor":111,"x":1092,"y":1069,"style":1100},"text-anchor:middle;fill:currentColor;font:600 12px sans-serif","ul: grid template changes",[117,1103],{"x":1104,"y":1073,"width":1105,"height":1106,"rx":795,"fill":1062,"stroke":1063,"strokeWidth":373,"opacity":1066},"410","116","54",[117,1108],{"x":1109,"y":1073,"width":1105,"height":1106,"rx":795,"fill":1062,"stroke":1063,"strokeWidth":373,"opacity":1066},"534",[117,1111],{"x":1104,"y":1082,"width":1105,"height":1106,"rx":795,"fill":1062,"stroke":1063,"strokeWidth":373,"opacity":1066},[117,1113],{"x":1109,"y":1082,"width":1105,"height":1106,"rx":795,"fill":1062,"stroke":1063,"strokeWidth":373,"opacity":1066},[109,1115,1116],{"textAnchor":111,"x":1092,"y":1088,"style":142},"the container itself is styled",[20,1118,1119,1120,379,1123,379,1125,379,1128,1131,1132,1134],{},"Because the container is the subject, the declarations can be layout declarations: ",[15,1121,1122],{},"display",[15,1124,69],{},[15,1126,1127],{},"flex-wrap",[15,1129,1130],{},"gap",". That is the practical difference between the old item-based trick and the new parent-based one, and it is why quantity queries went from a curiosity to a mainstream layout tool once ",[15,1133,17],{}," shipped.",[41,1136,1138],{"id":1137},"variation-counting-only-visible-items","Variation: counting only visible items",[20,1140,1141,1142,1145,1146,1149,1150,1152,1153,1156],{},"A filterable list hides items with the ",[15,1143,1144],{},"hidden"," attribute or a class, and ",[15,1147,1148],{},":nth-child"," counts hidden elements just like visible ones. The selector-list argument to ",[15,1151,1148],{}," — the ",[15,1154,1155],{},"of S"," syntax — fixes this by counting only siblings that match a selector.",[221,1158,1162],{"className":1159,"code":1160,"language":1161,"meta":226,"style":226},"language-css shiki shiki-themes github-light-high-contrast github-dark-high-contrast","\u002F* Count only items that are not hidden. With five items where two are\n   hidden, :nth-child(4 of :not([hidden])) does not exist, so this list\n   is treated as having three items and keeps the three-up layout. *\u002F\n.results:has(> :nth-child(4 of :not([hidden]))) {\n  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));\n}\n\n\u002F* An explicit empty state when every item is filtered out. *\u002F\n.results:not(:has(> :not([hidden]))) {\n  display: grid;\n  place-items: center;\n  min-height: 8rem;\n}\n\n.results:not(:has(> :not([hidden])))::before {\n  content: \"No results match these filters.\";\n  color: #475569;\n}\n","css",[15,1163,1164,1169,1174,1179,1208,1240,1245,1249,1254,1277,1288,1300,1313,1317,1321,1347,1359,1371],{"__ignoreMap":226},[230,1165,1166],{"class":232,"line":233},[230,1167,1168],{"class":449},"\u002F* Count only items that are not hidden. With five items where two are\n",[230,1170,1171],{"class":232,"line":251},[230,1172,1173],{"class":449},"   hidden, :nth-child(4 of :not([hidden])) does not exist, so this list\n",[230,1175,1176],{"class":232,"line":271},[230,1177,1178],{"class":449},"   is treated as having three items and keeps the three-up layout. *\u002F\n",[230,1180,1181,1184,1186,1188,1190,1192,1194,1197,1200,1203,1205],{"class":232,"line":281},[230,1182,1183],{"class":244},".results:has",[230,1185,545],{"class":236},[230,1187,192],{"class":366},[230,1189,652],{"class":244},[230,1191,545],{"class":236},[230,1193,795],{"class":244},[230,1195,1196],{"class":236}," of :",[230,1198,1199],{"class":244},"n",[230,1201,1202],{"class":236},"ot([hidde",[230,1204,1199],{"class":244},[230,1206,1207],{"class":236},"]))) {\n",[230,1209,1210,1213,1215,1217,1219,1221,1223,1225,1227,1230,1232,1234,1236,1238],{"class":232,"line":299},[230,1211,1212],{"class":244},"  grid-template-columns",[230,1214,360],{"class":236},[230,1216,730],{"class":244},[230,1218,545],{"class":236},[230,1220,864],{"class":244},[230,1222,379],{"class":236},[230,1224,869],{"class":244},[230,1226,545],{"class":236},[230,1228,1229],{"class":244},"10",[230,1231,395],{"class":366},[230,1233,379],{"class":236},[230,1235,461],{"class":244},[230,1237,464],{"class":366},[230,1239,884],{"class":236},[230,1241,1242],{"class":232,"line":324},[230,1243,1244],{"class":236},"}\n",[230,1246,1247],{"class":232,"line":338},[230,1248,405],{"emptyLinePlaceholder":404},[230,1250,1251],{"class":232,"line":348},[230,1252,1253],{"class":449},"\u002F* An explicit empty state when every item is filtered out. *\u002F\n",[230,1255,1256,1259,1261,1263,1265,1267,1270,1273,1275],{"class":232,"line":401},[230,1257,1258],{"class":244},".results:not",[230,1260,545],{"class":236},[230,1262,645],{"class":244},[230,1264,545],{"class":236},[230,1266,192],{"class":366},[230,1268,1269],{"class":244}," :not",[230,1271,1272],{"class":236},"([",[230,1274,1144],{"class":244},[230,1276,1207],{"class":236},[230,1278,1279,1282,1284,1286],{"class":232,"line":408},[230,1280,1281],{"class":244},"  display",[230,1283,360],{"class":236},[230,1285,425],{"class":244},[230,1287,428],{"class":236},[230,1289,1290,1293,1295,1298],{"class":232,"line":417},[230,1291,1292],{"class":244},"  place-items",[230,1294,360],{"class":236},[230,1296,1297],{"class":244},"center",[230,1299,428],{"class":236},[230,1301,1302,1305,1307,1309,1311],{"class":232,"line":431},[230,1303,1304],{"class":244},"  min-height",[230,1306,360],{"class":236},[230,1308,123],{"class":244},[230,1310,395],{"class":366},[230,1312,428],{"class":236},[230,1314,1315],{"class":232,"line":446},[230,1316,1244],{"class":236},[230,1318,1319],{"class":232,"line":453},[230,1320,405],{"emptyLinePlaceholder":404},[230,1322,1323,1325,1327,1329,1331,1333,1335,1337,1339,1342,1345],{"class":232,"line":469},[230,1324,1258],{"class":244},[230,1326,545],{"class":236},[230,1328,645],{"class":244},[230,1330,545],{"class":236},[230,1332,192],{"class":366},[230,1334,1269],{"class":244},[230,1336,1272],{"class":236},[230,1338,1144],{"class":244},[230,1340,1341],{"class":236},"])))",[230,1343,1344],{"class":244},"::before",[230,1346,414],{"class":236},[230,1348,1349,1352,1354,1357],{"class":232,"line":475},[230,1350,1351],{"class":244},"  content",[230,1353,360],{"class":236},[230,1355,1356],{"class":265},"\"No results match these filters.\"",[230,1358,428],{"class":236},[230,1360,1361,1364,1366,1369],{"class":232,"line":480},[230,1362,1363],{"class":244},"  color",[230,1365,360],{"class":236},[230,1367,1368],{"class":244},"#475569",[230,1370,428],{"class":236},[230,1372,1373],{"class":232,"line":493},[230,1374,1244],{"class":236},[20,1376,1377,1378,1386,1387,1390],{},"The empty-state rule is a small bonus: a container with no visible children can show its own message through generated content. For anything a screen reader must announce, keep the real message in the DOM inside a live region instead, because generated content is not reliably announced when it appears. The same \"does this container hold anything?\" logic powers ",[29,1379,1381,1382,1385],{"href":1380},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fcontent-aware-card-layouts-with-has\u002F","content-aware card layouts with ",[1383,1384],"has",{},"()",", where the question is which ",[24,1388,1389],{},"kinds"," of children exist rather than how many.",[41,1392,1394],{"id":1393},"combining-counts-with-width","Combining counts with width",[20,1396,1397,1398,1402],{},"A count tells you how many items there are; a ",[29,1399,1401],{"href":1400},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002F","container query"," tells you how much room they have. The two are independent inputs and compose cleanly: a navigation bar with up to four links can stay a row at any width above 24rem, while one with seven links needs 40rem before it can be a row.",[221,1404,1406],{"className":1159,"code":1405,"language":1161,"meta":226,"style":226},".nav { container-type: inline-size; }\n\n.nav__list { display: flex; flex-direction: column; gap: 0.25rem; }\n\n\u002F* Few links: a row as soon as there is modest room. *\u002F\n@container (width > 24rem) {\n  .nav__list:not(:has(> :nth-child(5))) { flex-direction: row; }\n}\n\n\u002F* Many links: only a row when there is plenty of room. *\u002F\n@container (width > 40rem) {\n  .nav__list:has(> :nth-child(5)) { flex-direction: row; }\n}\n",[15,1407,1408,1421,1425,1462,1466,1471,1479,1510,1514,1518,1523,1530,1556],{"__ignoreMap":226},[230,1409,1410,1413,1415,1418],{"class":232,"line":233},[230,1411,1412],{"class":244},".nav",[230,1414,354],{"class":236},[230,1416,1417],{"class":244},"container-type",[230,1419,1420],{"class":236},": inline-size; }\n",[230,1422,1423],{"class":232,"line":251},[230,1424,405],{"emptyLinePlaceholder":404},[230,1426,1427,1430,1432,1434,1436,1439,1441,1444,1446,1449,1451,1453,1455,1458,1460],{"class":232,"line":271},[230,1428,1429],{"class":244},".nav__list",[230,1431,354],{"class":236},[230,1433,1122],{"class":244},[230,1435,360],{"class":236},[230,1437,1438],{"class":244},"flex",[230,1440,385],{"class":236},[230,1442,1443],{"class":244},"flex-direction",[230,1445,360],{"class":236},[230,1447,1448],{"class":244},"column",[230,1450,385],{"class":236},[230,1452,1130],{"class":244},[230,1454,360],{"class":236},[230,1456,1457],{"class":244},"0.25",[230,1459,395],{"class":366},[230,1461,398],{"class":236},[230,1463,1464],{"class":232,"line":281},[230,1465,405],{"emptyLinePlaceholder":404},[230,1467,1468],{"class":232,"line":299},[230,1469,1470],{"class":449},"\u002F* Few links: a row as soon as there is modest room. *\u002F\n",[230,1472,1473,1476],{"class":232,"line":324},[230,1474,1475],{"class":366},"@container",[230,1477,1478],{"class":236}," (width > 24rem) {\n",[230,1480,1481,1484,1486,1488,1490,1492,1494,1496,1498,1501,1503,1505,1508],{"class":232,"line":338},[230,1482,1483],{"class":244},"  .nav__list:not",[230,1485,545],{"class":236},[230,1487,645],{"class":244},[230,1489,545],{"class":236},[230,1491,192],{"class":366},[230,1493,652],{"class":244},[230,1495,545],{"class":236},[230,1497,1065],{"class":244},[230,1499,1500],{"class":236},"))) { ",[230,1502,1443],{"class":244},[230,1504,360],{"class":236},[230,1506,1507],{"class":244},"row",[230,1509,398],{"class":236},[230,1511,1512],{"class":232,"line":348},[230,1513,1244],{"class":236},[230,1515,1516],{"class":232,"line":401},[230,1517,405],{"emptyLinePlaceholder":404},[230,1519,1520],{"class":232,"line":408},[230,1521,1522],{"class":449},"\u002F* Many links: only a row when there is plenty of room. *\u002F\n",[230,1524,1525,1527],{"class":232,"line":417},[230,1526,1475],{"class":366},[230,1528,1529],{"class":236}," (width > 40rem) {\n",[230,1531,1532,1535,1537,1539,1541,1543,1545,1548,1550,1552,1554],{"class":232,"line":431},[230,1533,1534],{"class":244},"  .nav__list:has",[230,1536,545],{"class":236},[230,1538,192],{"class":366},[230,1540,652],{"class":244},[230,1542,545],{"class":236},[230,1544,1065],{"class":244},[230,1546,1547],{"class":236},")) { ",[230,1549,1443],{"class":244},[230,1551,360],{"class":236},[230,1553,1507],{"class":244},[230,1555,398],{"class":236},[230,1557,1558],{"class":232,"line":446},[230,1559,1244],{"class":236},[20,1561,1562,1563,1567],{},"This is a genuinely new capability. Neither a media query nor a container query alone can express \"the threshold depends on how much content there is\", but the two together can. For the fully automatic version of this idea, where items wrap based on their own sizes, see ",[29,1564,1566],{"href":1565},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries\u002F","responsive navigation without media queries",".",[41,1569,1571],{"id":1570},"browser-support","Browser support",[20,1573,1574,1576,1577,1580,1581,1583,1584,1586,1587,1589,1590,1593],{},[15,1575,17],{}," is supported in Chrome and Edge 105+, Firefox 121+ and Safari 15.4+. ",[15,1578,1579],{},":nth-child()"," itself is universal, and the ",[15,1582,1155],{}," selector-list argument is supported in current versions of all three engines, having arrived in Safari long before the others. In a browser without ",[15,1585,17],{},", every rule on this page is dropped, and the gallery keeps its single-column default — a safe fallback. To keep the two-column layout for older engines, wrap the ",[15,1588,17],{}," rules in ",[15,1591,1592],{},"@supports selector(:has(*))"," and give the default rule two columns outside that block.",[41,1595,1597],{"id":1596},"faq","FAQ",[20,1599,1600,1604,1605,1608],{},[1601,1602,1603],"strong",{},"How do I select a container that has at least four children?","\nUse ",[15,1606,1607],{},".list:has(> :nth-child(4))",". The fourth child only exists when there are four or more, so the parent matches exactly when the count is four or higher.",[20,1610,1611,1614,1615,1617],{},[1601,1612,1613],{},"How do I select a container with exactly three children?","\nCombine a lower and an upper bound: ",[15,1616,170],{},". The first part requires at least three, the second rules out four or more.",[20,1619,1620,1623,1624,1626,1627,1630,1631,1633,1634,1636,1637,1640],{},[1601,1621,1622],{},"Do hidden children count toward a quantity query?","\nYes. ",[15,1625,1148],{}," counts elements in the DOM regardless of ",[15,1628,1629],{},"display: none"," or the ",[15,1632,1144],{}," attribute, so a filtered list that hides items with CSS still reports its full count. Remove items from the DOM or add an ",[15,1635,1155],{}," filter such as ",[15,1638,1639],{},":nth-child(4 of :not([hidden]))"," when only visible items should count.",[20,1642,1643,1649,1650,1652,1653,1655],{},[1601,1644,1645,1646,1648],{},"What did quantity queries look like before ",[15,1647,17],{},"?","\nThey styled the children rather than the parent, using selectors like ",[15,1651,57],{}," to match every item in a list of four or more. That works for the items but can never change the container's own grid or flex rules, which ",[15,1654,17],{}," now can.",[41,1657,1659],{"id":1658},"related","Related",[1661,1662,1663,1672,1680,1689,1696],"ul",{},[1664,1665,1666,1671],"li",{},[29,1667,1668,1669,1385],{"href":31},"Parent-Aware Layouts With ",[1383,1670],{}," — the parent guide to relational selectors in layout.",[1664,1673,1674,1679],{},[29,1675,1676,1677,1385],{"href":1380},"Content-Aware Card Layouts With ",[1383,1678],{}," — layouts driven by which children exist.",[1664,1681,1682,1688],{},[29,1683,1685,1687],{"href":1684},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fhas-selector-performance\u002F",[1383,1686],{},"() Selector Performance"," — keeping relational selectors cheap.",[1664,1690,1691,1695],{},[29,1692,1694],{"href":1693},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids\u002F","auto-fit and minmax() Grids"," — the grid used for the four-plus layout.",[1664,1697,1698,1702],{},[29,1699,1701],{"href":1700},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties\u002F","Staggered List Animations With Custom Properties"," — animating items as a list grows.",[343,1704,1705],{},"html pre.shiki code .suds8, html code.shiki .suds8{--shiki-default:#0E1116;--shiki-dark:#F0F3F6}html pre.shiki code .sne4z, html code.shiki .sne4z{--shiki-default:#024C1A;--shiki-dark:#72F088}html pre.shiki code .s-5SL, html code.shiki .s-5SL{--shiki-default:#023B95;--shiki-dark:#91CBFF}html pre.shiki code .sT6z2, html code.shiki .sT6z2{--shiki-default:#032563;--shiki-dark:#ADDCFF}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);}",{"title":226,"searchDepth":251,"depth":251,"links":1707},[1708,1709,1710,1711,1712,1713,1714,1715,1716],{"id":43,"depth":251,"text":44},{"id":79,"depth":251,"text":80},{"id":211,"depth":251,"text":212},{"id":1019,"depth":251,"text":1020},{"id":1137,"depth":251,"text":1138},{"id":1393,"depth":251,"text":1394},{"id":1570,"depth":251,"text":1571},{"id":1596,"depth":251,"text":1597},{"id":1658,"depth":251,"text":1659},"Change a layout by how many children it has: :has() with :nth-child and :nth-last-child selects a parent holding at least, at most or exactly N items.","md",{"pageTitle":1720,"datePublished":1721,"dateModified":1721,"faq":1722},"Quantity Queries With :has() and nth-child","2026-09-18",[1723,1725,1727,1729],{"q":1603,"a":1724},"Use .list:has(> :nth-child(4)). The fourth child only exists when there are four or more, so the parent matches exactly when the count is four or higher.",{"q":1613,"a":1726},"Combine a lower and an upper bound: .list:has(> :nth-child(3)):not(:has(> :nth-child(4))). The first part requires at least three, the second rules out four or more.",{"q":1622,"a":1728},"Yes. :nth-child counts elements in the DOM regardless of display: none or the hidden attribute, so a filtered list that hides items with CSS still reports its full count. Remove items from the DOM or add an of S filter such as :nth-child(4 of :not([hidden])) when only visible items should count.",{"q":1730,"a":1731},"What did quantity queries look like before :has()?","They styled the children rather than the parent, using selectors like li:nth-last-child(n+4), li:nth-last-child(n+4) ~ li to match every item in a list of four or more. That works for the items but can never change the container's own grid or flex rules, which :has() now can.","\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has",{"title":5,"description":1717},"mastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fquantity-queries-with-has\u002Findex","XFCPyGbUAv-p1rR3hlDjy3z8TY2n5ds0DavcrkjzL2o",[1737,1740,1743,1746,1749,1752,1755,1758,1761,1764,1767,1770,1773,1776,1779,1782,1785,1788,1791,1794,1797,1800,1803,1806,1809,1812,1815,1818,1821,1824,1827,1830,1833,1836,1839,1842,1845,1848,1851,1854,1857,1860,1863,1866,1869,1872,1875,1878,1881,1884,1887,1890,1893,1896,1899,1902,1905,1908,1911,1914,1917,1920,1923,1926,1929,1932,1935,1938,1941,1944,1947,1950,1953,1956,1959,1962,1965,1968,1971,1974,1977,1980,1983,1986,1989,1992,1995,1998,2001,2004,2007,2010,2013,2016,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,2158,2161,2164,2167,2170,2173,2176,2179,2182,2185,2188,2191,2194,2197,2200,2203,2206,2209,2212,2215,2216,2219,2222,2225,2228,2231,2234,2237,2240,2243,2246,2249,2252,2255,2258,2261,2264,2267,2270,2273,2276,2279,2282,2285,2288,2291],{"path":1738,"title":1739},"\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":1741,"title":1742},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fflashing-content-and-seizure-thresholds","Flashing Content and Seizure Thresholds",{"path":1744,"title":1745},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fforced-colors-mode-and-animations","Forced Colors Mode and Animations",{"path":1747,"title":1748},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations","Accessibility in CSS Animations: Patterns, Specs & Best Practices",{"path":1750,"title":1751},"\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":1753,"title":1754},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fprefers-reduced-motion-recipes","prefers-reduced-motion Recipes: A Reduction for Every Common Effect",{"path":1756,"title":1757},"\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":1759,"title":1760},"\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":1762,"title":1763},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fvestibular-safe-animation-patterns","Vestibular-Safe Animation Patterns: Why Some Motion Makes People Sick",{"path":1765,"title":1766},"\u002Fcss-only-micro-interactions-animations\u002Faccessibility-in-css-animations\u002Fwcag-motion-success-criteria","WCAG Motion Success Criteria: What Each One Actually Requires",{"path":1768,"title":1769},"\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":1771,"title":1772},"\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":1774,"title":1775},"\u002Fcss-only-micro-interactions-animations\u002Fclip-path-and-mask-animations","Clip-Path & Mask Animations: Animating Visibility Instead of Position",{"path":1777,"title":1778},"\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":1780,"title":1781},"\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":1783,"title":1784},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fanimating-gradients","Animating CSS Gradients: Smooth Colour Motion Without Jumps",{"path":1786,"title":1787},"\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":1789,"title":1790},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions","Color & Theme Transitions: Colour as Part of the Motion System",{"path":1792,"title":1793},"\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":1795,"title":1796},"\u002Fcss-only-micro-interactions-animations\u002Fcolor-and-theme-transitions\u002Fsmooth-theme-switching-transitions","Smooth Theme Switching: Crossfades, Circular Reveals and No Flash",{"path":1798,"title":1799},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fcontainer-query-hover-affordances","Container Query Hover Affordances: When Narrow Means Persistent, Not Hidden",{"path":1801,"title":1802},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion","Container-Aware Motion: Animation Sized by the Space a Component Actually Has",{"path":1804,"title":1805},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Flayout-change-animations-at-container-breakpoints","Animating Changes at Container Breakpoints",{"path":1807,"title":1808},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fmotion-driven-by-container-style-queries","Motion Driven by Container Style Queries",{"path":1810,"title":1811},"\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":1813,"title":1814},"\u002Fcss-only-micro-interactions-animations\u002Fcontainer-aware-motion\u002Fsuppressing-motion-in-small-containers","Suppressing Motion in Small Containers: Deliberately Animating Nothing",{"path":1816,"title":1817},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fcontrolling-css-animations-from-javascript","Controlling CSS Animations From JavaScript",{"path":1819,"title":1820},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api","CSS Animation vs the Web Animations API: A Decision Guide",{"path":1822,"title":1823},"\u002Fcss-only-micro-interactions-animations\u002Fcss-animation-vs-web-animations-api\u002Fwaapi-vs-css-for-interruptible-ui","Interruptible UI: CSS Transitions vs WAAPI",{"path":1825,"title":1826},"\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":1828,"title":1829},"\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":1831,"title":1832},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fcustom-property-fallbacks-and-invalid-values","Custom Property Fallbacks and Invalid Values",{"path":1834,"title":1835},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Ffluid-spacing-tokens-driving-transition-durations","Fluid Spacing Tokens That Drive Transition Durations",{"path":1837,"title":1838},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture","CSS Custom Properties Architecture: Scalable Design Systems & Dynamic UI",{"path":1840,"title":1841},"\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":1843,"title":1844},"\u002Fcss-only-micro-interactions-animations\u002Fcss-custom-properties-architecture\u002Fscoping-custom-properties-to-components","Scoping Custom Properties to Components",{"path":1846,"title":1847},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fcss-transition-timing-functions","CSS Transition Timing Functions: ease, cubic-bezier(), steps() and linear()",{"path":1849,"title":1850},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals","CSS Transition Fundamentals: Architecture, Performance & Patterns",{"path":1852,"title":1853},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Finterrupted-and-reversing-transitions","Interrupted and Reversing Transitions: What Happens Mid-Flight",{"path":1855,"title":1856},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Fstarting-style-entry-animations","@starting-style: Animating an Element's Very First Style Change",{"path":1858,"title":1859},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-delay-choreography","Choreographing Motion With transition-delay",{"path":1861,"title":1862},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransition-shorthand-and-multiple-properties","The transition Shorthand and Multiple Properties",{"path":1864,"title":1865},"\u002Fcss-only-micro-interactions-animations\u002Fcss-transition-fundamentals\u002Ftransitioning-display-with-allow-discrete","Transitioning display with transition-behavior: allow-discrete and @starting-style",{"path":1867,"title":1868},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fanimating-dialog-open-and-close","Animating \u003Cdialog> Open and Close: Both Directions, No Library",{"path":1870,"title":1871},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fbackdrop-animations","Animating ::backdrop: Fades and Blurs Behind Dialogs and Popovers",{"path":1873,"title":1874},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations","Dialog & Popover Animations: Motion for the Top Layer",{"path":1876,"title":1877},"\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":1879,"title":1880},"\u002Fcss-only-micro-interactions-animations\u002Fdialog-and-popover-animations\u002Fpopover-entry-and-exit-transitions","Popover Menus That Animate From Their Anchor",{"path":1882,"title":1883},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fchoosing-animation-durations","Choosing Animation Durations: How Long Motion Should Last",{"path":1885,"title":1886},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fcubic-bezier-overshoot-and-anticipation","Overshoot and Anticipation With cubic-bezier(): Motion With Character",{"path":1888,"title":1889},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design\u002Fentry-vs-exit-easing","Entry vs Exit Easing: Different Curves for Arriving and Leaving",{"path":1891,"title":1892},"\u002Fcss-only-micro-interactions-animations\u002Feasing-and-motion-design","Easing & Motion Design: Making CSS Motion Feel Intentional",{"path":1894,"title":1895},"\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":1897,"title":1898},"\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":1900,"title":1901},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Faccessible-css-only-tooltips","Accessible CSS-Only Tooltips and Hover Cards With  and ",{"path":1903,"title":1904},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Fbutton-press-and-active-states","Button Press and  States",{"path":1906,"title":1907},"\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":1909,"title":1910},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design\u002Ffocus-within-form-patterns"," Form Patterns: Styling a Group From the Field Inside It",{"path":1912,"title":1913},"\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":1915,"title":1916},"\u002Fcss-only-micro-interactions-animations\u002Fhover-focus-state-design","Hover & Focus State Design: Spec-Compliant Patterns for Modern UIs",{"path":1918,"title":1919},"\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":1921,"title":1922},"\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":1924,"title":1925},"\u002Fcss-only-micro-interactions-animations","CSS-Only Micro-Interactions & Animations: Architecture, Performance & Implementation",{"path":1927,"title":1928},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fanimation-composition-and-stacking","Stacking Animations With animation-composition",{"path":1930,"title":1931},"\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":1933,"title":1934},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcontainer-query-triggered-keyframe-animations","Container-Query-Triggered Keyframe Animations: Animate Differently per Available Space",{"path":1936,"title":1937},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fcss-only-accordions-and-disclosure","CSS-Only Accordions and Disclosure Widgets with details and summary",{"path":1939,"title":1940},"\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":1942,"title":1943},"\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":1945,"title":1946},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns","Keyframe Animation Patterns: Spec-Compliant Architectures for Modern UIs",{"path":1948,"title":1949},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fmulti-step-keyframes-and-per-keyframe-easing","Multi-Step Keyframes and Per-Keyframe Easing",{"path":1951,"title":1952},"\u002Fcss-only-micro-interactions-animations\u002Fkeyframe-animation-patterns\u002Fstaggered-list-animations-with-custom-properties","Staggered List Animations Using --i Index Custom Properties",{"path":1954,"title":1955},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fanimating-box-shadow-and-filters-cheaply","Animating box-shadow and Filters Cheaply",{"path":1957,"title":1958},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcontain-property-for-animation-performance","The contain Property for Animation Performance",{"path":1960,"title":1961},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Fcss-triggers-layout-paint-composite","Layout, Paint and Composite: What Triggers What",{"path":1963,"title":1964},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration","Performance & GPU Acceleration in CSS: A Developer’s Blueprint",{"path":1966,"title":1967},"\u002Fcss-only-micro-interactions-animations\u002Fperformance-gpu-acceleration\u002Foptimizing-css-animations-for-60fps","Optimizing CSS Animations for 60fps: Budgeting the Frame",{"path":1969,"title":1970},"\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":1972,"title":1973},"\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":1975,"title":1976},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations","Scroll-Driven Animations: Binding Motion to Scroll Position in Pure CSS",{"path":1978,"title":1979},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-animation-fallbacks","Shipping Scroll-Driven Animations Without Breaking Anything",{"path":1981,"title":1982},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-driven-parallax-effects","Scroll-Driven Parallax Effects in CSS",{"path":1984,"title":1985},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-progress-bar-without-javascript","A Reading Progress Bar Driven by scroll(root)",{"path":1987,"title":1988},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fscroll-triggered-reveal-animations","Reveal-on-Scroll with view() and animation-range",{"path":1990,"title":1991},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Ftimeline-scope-for-cross-element-animations","timeline-scope for Cross-Element Animations",{"path":1993,"title":1994},"\u002Fcss-only-micro-interactions-animations\u002Fscroll-driven-animations\u002Fview-timeline-and-animation-range","View Timelines and animation-range",{"path":1996,"title":1997},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fcross-document-view-transitions","Cross-Document View Transitions",{"path":1999,"title":2000},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers","View Transitions for CSS Developers: the Pseudo-Element Tree, Snapshots, and Named Elements",{"path":2002,"title":2003},"\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":2005,"title":2006},"\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":2008,"title":2009},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transition-types-and-classes","View Transition Types and Classes",{"path":2011,"title":2012},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-for-list-reordering","View Transitions for List Reordering",{"path":2014,"title":2015},"\u002Fcss-only-micro-interactions-animations\u002Fview-transitions-for-css-developers\u002Fview-transitions-with-reduced-motion","Honouring prefers-reduced-motion in View Transitions",{"path":370,"title":2017},"Modern CSS Layouts & Micro-Interactions",{"path":2019,"title":2020},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioned-tooltips","Anchor-Positioned Tooltips: Tethering, Flipping, and Getting the Semantics Right",{"path":2022,"title":2023},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-positioning-fallbacks","Anchor Positioning Fallbacks: A Graceful Floor for Older Browser Versions",{"path":2025,"title":2026},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fanchor-size-for-matching-widths","anchor-size(): Overlays That Match Their Trigger's Size",{"path":2028,"title":2029},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays","CSS Anchor Positioning and Overlays: Tethering Elements Without JavaScript",{"path":2031,"title":2032},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-attribute-and-css-styling","The popover Attribute: Top-Layer Overlays With No JavaScript",{"path":2034,"title":2035},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fpopover-light-dismiss-and-stacking","Popover Light Dismiss, Nesting and Stacking",{"path":2037,"title":2038},"\u002Fmastering-container-queries-responsive-layouts\u002Fanchor-positioning-and-overlays\u002Fposition-area-grid-explained","position-area: The Anchor Placement Grid",{"path":2040,"title":2041},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fcontainer-query-polyfill-tradeoffs","Container Query Polyfills: What They Cost and When to Skip Them",{"path":2043,"title":2044},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ffeature-detection-with-supports","Feature Detection with @supports: Syntax, Semantics, and the Traps",{"path":2046,"title":2047},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fhandling-container-query-fallbacks-for-older-browsers","Handling Container Query Fallbacks for Older Browsers",{"path":2049,"title":2050},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks","Container Query Fallbacks: Spec-Compliant CSS Strategies for Legacy Browsers",{"path":2052,"title":2053},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Fintrinsic-layout-fallbacks-without-queries","Intrinsic Layout Fallbacks: Baselines That Adapt Without Any Query",{"path":2055,"title":2056},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-fallbacks\u002Ftesting-fallbacks-without-old-browsers","Testing CSS Fallbacks Without an Old Browser",{"path":2058,"title":2059},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-queries-inside-css-nesting","Container Queries Inside CSS Nesting: Keeping Responses Next to the Styles They Change",{"path":2061,"title":2062},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-query-range-and-logic-operators","Container Query Range Syntax and Logic Operators",{"path":2064,"title":2065},"\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":2067,"title":2068},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-type-size-vs-inline-size","Choosing container-type: inline-size, size, or normal",{"path":2070,"title":2071},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fcontainer-vs-media-queries-comparison","Container vs Media Queries: Choosing the Right Reference Box",{"path":2073,"title":2074},"\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":2076,"title":2077},"\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":2079,"title":2080},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics","Container Query Syntax Basics",{"path":2082,"title":2083},"\u002Fmastering-container-queries-responsive-layouts\u002Fcontainer-query-syntax-basics\u002Fnesting-and-naming-container-queries","Nesting and Naming Container Queries: Targeting the Right Ancestor",{"path":2085,"title":2086},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fauto-fit-minmax-responsive-grids","Responsive Grids with repeat(auto-fit, minmax())",{"path":2088,"title":2089},"\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":2091,"title":2092},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fgrid-auto-flow-dense-packing","grid-auto-flow: dense for Packed Layouts",{"path":2094,"title":2095},"\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":2097,"title":2098},"\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":2100,"title":2101},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts","CSS Grid and Subgrid Layouts for Responsive Interfaces",{"path":2103,"title":2104},"\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":2106,"title":2107},"\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":2109,"title":2110},"\u002Fmastering-container-queries-responsive-layouts\u002Fcss-grid-and-subgrid-layouts\u002Fsubgrid-vs-nested-grid","Subgrid vs an Independently Nested Grid",{"path":2112,"title":2113},"\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":2115,"title":2116},"\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":2118,"title":2119},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-grow-and-flex-shrink-explained","flex-grow and flex-shrink Explained",{"path":2121,"title":2122},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflex-wrap-intrinsic-responsive-rows","Breakpoint-Free Responsive Rows With flex-wrap and flex-basis",{"path":2124,"title":2125},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns\u002Fflexbox-gap-and-spacing","Flexbox gap vs Margins: Spacing Items Without Edge Hacks",{"path":2127,"title":2128},"\u002Fmastering-container-queries-responsive-layouts\u002Fflexbox-layout-patterns","Flexbox Layout Patterns: One-Dimensional Layout for Real Components",{"path":2130,"title":2131},"\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":2133,"title":2134},"\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":2136,"title":2137},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Fdebugging-clamp-values","Debugging clamp(): Values That Are Ignored, Stuck or Never Fluid",{"path":2139,"title":2140},"\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":2142,"title":2143},"\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":2145,"title":2146},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-type-accessibility-and-zoom","Fluid Type, Accessibility and Zoom: The vw-Only Trap",{"path":2148,"title":2149},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp\u002Ffluid-typography-without-javascript","Fluid Typography Without JavaScript: A Precision CSS Reference",{"path":2151,"title":2152},"\u002Fmastering-container-queries-responsive-layouts\u002Ffluid-typography-with-clamp","Fluid Typography with clamp(): A Practical Guide for Modern CSS",{"path":2154,"title":2155},"\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":2157,"title":38},"\u002Fmastering-container-queries-responsive-layouts",{"path":2159,"title":2160},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Faspect-ratio-for-responsive-media","Using aspect-ratio for Responsive Media and Preventing Layout Shift",{"path":2162,"title":2163},"\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":2165,"title":2166},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques","Intrinsic Sizing Techniques: Modern CSS Layouts for Responsive UI",{"path":2168,"title":2169},"\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":2171,"title":2172},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fmin-max-fit-content-explained","min-content, max-content, and fit-content() Explained",{"path":2174,"title":2175},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fobject-fit-and-object-position","object-fit and object-position: Images That Fit Any Box",{"path":2177,"title":2178},"\u002Fmastering-container-queries-responsive-layouts\u002Fintrinsic-sizing-techniques\u002Fpreventing-flex-and-grid-overflow","The min-width: auto Trap in Flex and Grid Layouts",{"path":2180,"title":2181},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-for-reset-and-tokens","Cascade Layers for Reset and Design Tokens",{"path":2183,"title":2184},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcascade-layers-vs-specificity-hacks","Cascade Layers vs Specificity Hacks: Ordering Instead of Escalating",{"path":2186,"title":2187},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fcss-scope-for-component-styles","@scope for Component Styles: Short Selectors That Cannot Leak",{"path":2189,"title":2190},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies","Modern CSS Reset Strategies: A Spec-Compliant Foundation",{"path":2192,"title":2193},"\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":2195,"title":2196},"\u002Fmastering-container-queries-responsive-layouts\u002Fmodern-css-reset-strategies\u002Fwriting-a-minimal-modern-reset","Writing a Minimal Modern CSS Reset: Every Line Justified",{"path":2198,"title":2199},"\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":2201,"title":2202},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has\u002Fempty-and-loading-states-with-has","Empty and Loading States With ()",{"path":2204,"title":2205},"\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":2207,"title":2208},"\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":2210,"title":2211},"\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":2213,"title":2214},"\u002Fmastering-container-queries-responsive-layouts\u002Fparent-aware-layouts-with-has","Parent-Aware Layouts With :has(): Letting Containers React to Their Contents",{"path":1732,"title":5},{"path":2217,"title":2218},"\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":2220,"title":2221},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-data-tables","Container Query Data Tables: Reflowing Tables to Cards",{"path":2223,"title":2224},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fcontainer-query-sidebar-layouts","Container Query Sidebar Layouts That Travel Between Contexts",{"path":2226,"title":2227},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns","Responsive Component Patterns: Architecture & Implementation",{"path":2229,"title":2230},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-forms-with-container-queries","Responsive Forms with Container Queries: Reflow Without Losing the Wiring",{"path":2232,"title":2233},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-hero-sections-with-container-queries","Responsive Hero Sections With Container Queries",{"path":2235,"title":2236},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-navigation-without-media-queries","Responsive Navigation Without Media Queries Using Container Queries",{"path":2238,"title":2239},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Fresponsive-pricing-tables","Responsive Pricing Tables: Aligned Features, a Clear Recommendation, Any Width",{"path":2241,"title":2242},"\u002Fmastering-container-queries-responsive-layouts\u002Fresponsive-component-patterns\u002Ftabs-that-become-accordions","Tabs That Become an Accordion: One Component, Two Layouts",{"path":2244,"title":2245},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts\u002Fcss-only-carousel-with-scroll-snap","A CSS-Only Carousel With Scroll Snap",{"path":2247,"title":2248},"\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":2250,"title":2251},"\u002Fmastering-container-queries-responsive-layouts\u002Fscroll-snap-and-overflow-layouts","Scroll Snap & Overflow Layouts: Designing Components That Scroll on Purpose",{"path":2253,"title":2254},"\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":2256,"title":2257},"\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":2259,"title":2260},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fcombining-size-and-style-queries","Combining Size and Style Container Queries",{"path":2262,"title":2263},"\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":2265,"title":2266},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state","Style Queries and Container State: Token-Driven Component Variants",{"path":2268,"title":2269},"\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":2271,"title":2272},"\u002Fmastering-container-queries-responsive-layouts\u002Fstyle-queries-and-container-state\u002Fstyle-query-component-variants","Component Variants With Style Queries: One Token, Many Looks",{"path":2274,"title":2275},"\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":2277,"title":2278},"\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":2280,"title":2281},"\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":2283,"title":2284},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout","Viewport Units & Mobile Layout: Designing for the Screen You Actually Get",{"path":2286,"title":2287},"\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":2289,"title":2290},"\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":2292,"title":2293},"\u002Fmastering-container-queries-responsive-layouts\u002Fviewport-units-and-mobile-layout\u002Fvirtual-keyboard-and-interactive-widget","Layouts That Survive the Virtual Keyboard",{"title":2295,"caption":2296,"height":2297,"resizable":404,"html":2298,"css":2299},"One gallery rule set, four item counts","The same CSS lays out galleries of one, two, three and five figures differently — no classes, only :has() counting children.",640,"\n\u003Cdiv class=\"gallery\">\u003Cfigure>One\u003C\u002Ffigure>\u003C\u002Fdiv>\n\u003Cdiv class=\"gallery\">\u003Cfigure>One\u003C\u002Ffigure>\u003Cfigure>Two\u003C\u002Ffigure>\u003C\u002Fdiv>\n\u003Cdiv class=\"gallery\">\u003Cfigure>One\u003C\u002Ffigure>\u003Cfigure>Two\u003C\u002Ffigure>\u003Cfigure>Three\u003C\u002Ffigure>\u003C\u002Fdiv>\n\u003Cdiv class=\"gallery\">\u003Cfigure>One\u003C\u002Ffigure>\u003Cfigure>Two\u003C\u002Ffigure>\u003Cfigure>Three\u003C\u002Ffigure>\u003Cfigure>Four\u003C\u002Ffigure>\u003Cfigure>Five\u003C\u002Ffigure>\u003C\u002Fdiv>","\nbody { display: grid; gap: 1.25rem; place-items: stretch; align-content: start; }\n.gallery {\n  display: grid;\n  gap: 0.5rem;\n  grid-template-columns: 1fr;\n}\n.gallery > figure {\n  margin: 0;\n  min-height: 4rem;\n  border-radius: 8px;\n  background: linear-gradient(135deg, #bfdbfe, #818cf8);\n  display: grid;\n  place-items: end start;\n  padding: 0.5rem;\n  color: #0f172a;\n}\n.gallery:not(:has(> :nth-child(2))) > figure { aspect-ratio: 21 \u002F 9; min-height: 0; }\n.gallery:has(> :nth-child(2)) { grid-template-columns: repeat(2, 1fr); }\n.gallery:has(> :nth-child(3)):not(:has(> :nth-child(4))) > :first-child { grid-row: span 2; }\n.gallery:has(> :nth-child(4)) { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); }",1789717746414]