Modern CSS is safe to use when the failure mode is intentional. The problem is not an old browser missing a feature; it is a card component that silently keeps mobile styles, a subgrid card whose button drifts above another card, or a registered custom property animation that snaps instead of interpolates.

The pattern I use in production is the same for every feature: write baseline CSS first, enhance inside a precise feature query, then name exactly what users get when the enhancement is ignored.
Grid: start with a non-Grid card layout
Do not jump straight to display: grid. The baseline should be a readable stacked or inline-block layout that does not depend on feature support.
Baseline CSS
/* Baseline: older browsers get a simple floated/flex-free card list */
.card-grid {
display: block;
font-size: 0;
}
.card-grid > .card {
display: inline-block;
width: 100%;
margin: 0 0 1.5rem;
vertical-align: top;
font-size: 1rem;
}
@media (min-width: 40em) {
.card-grid > .card {
width: calc(50% - 0.75rem);
margin-right: 1.5rem;
}
.card-grid > .card:nth-child(2n) {
margin-right: 0;
}
}
Enhancement CSS
/* Gap fallback first: margins remain harmless when gap is unsupported */
@supports (display: grid) {
.card-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1.5rem;
}
.card-grid > .card {
width: auto;
margin: 0;
}
}
Keep gap handling separate if you need to support very old Grid implementations. Margins are the safer fallback; once Grid is confirmed, reset those margins and use gap.
Unsupported result and risk
Without Grid, cards remain full width on small screens and two across at wider breakpoints. They may not match the final three-column composition, but text, images, and buttons remain usable. The main risk is whitespace around the last row, not broken content.

Subgrid: align nested card regions only when supported
Subgrid is useful when each card contains the same internal regions: media, title, description, and action. In older Safari versions, subgrid can be ignored even when the parent supports Grid. The result is uneven card heights and buttons that do not line up.
Baseline CSS
/* Baseline: each card manages its own internal stacking */
.product-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 1.5rem;
}
.product-card {
display: flex;
flex-direction: column;
padding: 1rem;
}
.card-media,
.card-title,
.card-body,
.card-actions {
margin: 0 0 0.875rem;
}
.card-actions {
margin-top: auto;
}
Enhancement CSS
/* Parent rows must exist before children can inherit them */
@supports (grid-template-rows: subgrid) {
.product-grid {
grid-template-rows: repeat(4, auto);
}
.product-card {
display: grid;
/* One card occupies all four parent row tracks. */
grid-row: span 4;
grid-template-rows: subgrid;
}
}
The four internal regions map directly to those four rows: .card-media lands in row 1, .card-title in row 2, .card-body in row 3, and .card-actions in row 4. That is why grid-row: span 4 is required.
Unsupported result and risk
Browsers without subgrid keep the flex card. margin-top: auto pushes the button toward the bottom, but titles and descriptions do not share row heights across cards. The page stays usable; exact cross-card button alignment is the part that degrades.
Container queries: complete component-level responsive example
Container queries let a card respond to its sidebar or main-column width instead of the viewport. This matters in dashboards and CMS layouts where the same component can appear in a narrow rail or a wide content area.
Baseline CSS
/* Baseline: safe single-column component for narrow sidebars and main content */
.article-card {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
padding: 1rem;
}
.article-card__media {
aspect-ratio: 16 / 9;
object-fit: cover;
width: 100%;
}
.article-card__title {
font-size: 1.125rem;
}
.article-card__actions {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
Enhancement CSS
/* Guard container-type too; unsupported browsers must ignore the whole system */
@supports (container-type: inline-size) {
.article-card-wrapper {
container-type: inline-size;
}
}
@container (min-width: 32rem) {
.article-card {
grid-template-columns: 12rem minmax(0, 1fr);
grid-template-areas:
"media title"
"media body"
"media actions";
align-items: start;
}
.article-card__media {
grid-area: media;
}
.article-card__title {
grid-area: title;
font-size: 1.375rem;
}
.article-card__body {
grid-area: body;
}
.article-card__actions {
grid-area: actions;
}
}
Put container-type inside @supports because containment changes layout even if the browser cannot evaluate the query. If containment were applied unconditionally, an older browser could establish a new formatting context or constrain the component without ever applying the wider @container rules.
Unsupported result and risk
Without container query support, the component stays single column. That satisfies both a narrow sidebar and a main content area: media sits above the title, body, and actions. In the main region it may look conservative, but it will not stay trapped in a broken two-up mobile/desktop hybrid.
@property: register typed custom properties carefully
@property is useful for animating angles, colors, and numbers as real typed values. A common example is a rotating gradient border. If registration is ignored, the custom property behaves like an ordinary untyped string token.
Baseline CSS
/* Static final visual state works without registration or animation */
.stat-card {
border: 1px solid #c7d2fe;
border-radius: 1rem;
padding: 1.25rem;
background:
linear-gradient(#fff, #fff) padding-box,
linear-gradient(135deg, #6366f1, #06b6d4) border-box;
}
Enhancement CSS
@property --angle {
syntax: "";
initial-value: 135deg;
inherits: false;
}
@supports (background: conic-gradient(from var(--angle), red, blue)) {
.stat-card {
--angle: 135deg;
border-color: transparent;
background:
linear-gradient(#fff, #fff) padding-box,
conic-gradient(
from var(--angle),
#6366f1,
#06b6d4,
#ec4899,
#6366f1
) border-box;
animation: rotate-border 6s linear infinite;
}
@keyframes rotate-border {
to {
--angle: 495deg;
}
}
}
Unsupported result and risk
If @property is ignored, the browser uses the static indigo/cyan gradient from the baseline. If the property is registered but the support query is wrong, the animation may not interpolate. Do not rely on registration failure to enforce syntax, initial values, or color/angle interpolation. Ordinary custom properties do not give you type checking; they are substituted as tokens.
Limits of CSS feature detection
@supports checks parsing support, not quality, consistency, or every related API. A browser can recognize grid-template-rows: subgrid in one engine version but still have implementation bugs elsewhere. Partial implementations, prefixes, and values added after the initial property can also produce misleading results.
Use the smallest meaningful declaration, such as @supports (container-type: inline-size), rather than testing only the at-rule name. For critical layouts, verify on real browsers or a service that runs the actual engines. Treat @supports as a routing mechanism, not a substitute for visual regression testing.
Practical decision table
| Feature | Recommended detection | Reliable baseline | Non-degradable requirement | Avoid when |
|---|---|---|---|---|
| Grid | @supports (display: grid) | block, inline-block, flex, or simple media-query columns | Precise automatic track placement | Supporting very old browsers without a tested fallback |
| Subgrid | @supports (grid-template-rows: subgrid) | Flex cards with margin-top: auto | Pixel-level row alignment across nested cards | Misaligned buttons would be mistaken for a content error |
| Container queries | @supports (container-type: inline-size) | Single-column component plus viewport breakpoints | Layout must change based on container width | You cannot control the wrapper element |
| @property | Test the exact typed value usage, not only registration | Static gradient/color/number final state | Smooth typed custom-property interpolation | The animation is essential to understanding the UI |
Project landing checklist
- Write and review the unsupported layout before adding any enhancement.
- Put baseline styles outside
@supports; put overrides inside the narrowest valid query. - Reset baseline margins, widths, and positioning when replacing them with Grid or container layouts.
- For subgrid, define the parent row tracks and verify every nested region maps to a track.
- Guard
container-type, not only@containerrules. - Give
@propertyanimations a static final style and never depend on untyped custom properties interpolating. - Test one old browser version for each risky feature and capture screenshots of both modes.
- Add visual regression tests for the fallback, not just the modern browser screenshot.
The goal is not to make every browser identical. It is to make the difference predictable: older browsers get a simpler, stable interface; modern browsers get the tighter alignment, container-aware composition, and richer motion.