PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchUse a CSS container query when a component should respond to the space available around it rather than to the browser window. Give an ancestor container-type: inline-size, then put a conditional @container rule around styles for its descendants.
How to write a basic container query
Start with the component’s default styling, make an ancestor an eligible query container, and then define the change inside @container. The query applies to descendants of that container; it does not select an arbitrary sibling or query the viewport.
<div class="post">
<article class="card">
<h2>Card title</h2>
<p>Card content</p>
</article>
</div>
.post {
container-type: inline-size;
}
.card h2 {
font-size: 1em;
}
@container (width > 700px) {
.card h2 {
font-size: 2em;
}
}
The 700px threshold is illustrative, not a recommended universal breakpoint. Choose a threshold based on when the component’s content and layout need to change. For the syntax and further examples, see MDN’s CSS container queries guide.
Choose between container queries and media queries
Use @container when a component’s behavior depends on the size of its containing region. This makes a card reusable in a wide main column or a narrow sidebar without needing to know where it will appear. Use @media when the trigger is a viewport or device condition. The right choice depends on what should cause the style change.
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Select the query container and axis
Use inline-size for width-responsive components
container-type: inline-size enables queries along the inline axis, which is usually the relevant dimension for a component adapting to available width. The inline axis is logical: it follows the writing mode and is not always identical to physical width.
Use size only when you need both axes
container-type: size enables queries against both inline and block dimensions. It also applies size containment: the container’s size is computed independently of its contents. Establish its dimensions through its layout context or explicit sizing; otherwise, the element may collapse because its children no longer determine its size. See MDN’s container-type reference for the property’s containment behavior.
Rank #2
Name a container when selection should be explicit
An unnamed query uses the nearest eligible ancestor. In nested components, that may not be the region you intended. Give the container a name and use that name in the query:
.post {
container: sidebar / inline-size;
}
@container sidebar (width > 700px) {
.card {
font-size: 2em;
}
}
The container shorthand sets the name and type; you can instead set container-name and container-type separately. Naming makes the target explicit when multiple eligible ancestors or nested components are involved. More detail is in MDN’s @container reference.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Use container-relative length units when fluid scaling helps
Container query length units let descendant lengths scale with the eligible size container. The units represent these proportions:
cqw: one percent of the container’s width.cqh: one percent of its height.cqi: one percent of its inline size.cqb: one percent of its block size.cqminandcqmax: the smaller and larger, respectively, ofcqiandcqb.
If no eligible container exists for the relevant axis, a container query length unit falls back to the corresponding small viewport unit. These units are useful for locally scaling type or spacing, but they are optional: use them only when fluid sizing suits the component. MDN documents the units in its container query guide.
Rank #4
Understand support for newer query types
MDN describes the established @container feature as widely available across browsers since February 2023, while cautioning that support varies for some parts. That broad availability statement should not be taken as a guarantee for every newer query type or syntax. Check the current compatibility data for the particular browsers and feature you plan to use.
Container queries include more than size queries: MDN’s current guide lists size, style, name-only, scroll-state, and anchored query types. Style queries are a separate feature family, not a way to inspect arbitrary computed CSS declarations. MDN’s guide discusses custom-property style queries and states that ordinary declaration/property checks through style() are not supported in any browser covered by that page. Its note about custom-property-only support is dated February 2024, so check the current compatibility information rather than treating that note as a current browser-version audit. Consult MDN’s container size and style query guide and the at-rule reference.
Recommended Free Tools
Best Value
Troubleshoot common container-query problems
- The query has no effect: confirm that an ancestor of the styled element has an eligible
container-type. A query cannot style the container based on itself; the rule targets its descendants. - The wrong region triggers the rule: an unnamed query selects the nearest eligible ancestor. Add a
container-nameand refer to it in the@containercondition. - The container becomes unexpectedly small or collapses: check whether it uses
container-type: size. Size containment prevents its children from determining its dimensions; provide sizing through the layout context or an explicit constraint, or useinline-sizeif only inline-axis queries are needed. - A query or unit seems unsupported: verify the exact syntax and query family in the browser versions you target. Support for the established size-query feature does not establish support for every newer query type.
- Container-relative sizing falls back unexpectedly: confirm there is an eligible query container for the axis used by the unit; without one, the unit uses the corresponding small viewport unit.
Or skip the browser setup
For a screenshot of a page demonstrating your component, you can use ScreenshotNeo’s API instead of setting up a browser capture script. This one-call cURL request saves a WebP screenshot; replace the URL with the page you want to capture and use your API key.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. For the product details, visit ScreenshotNeo.
Sign up free for 1,000 screenshots a month, with no card.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




