Start with semantic HTML, then use CSS to make the page adapt to its content, container, viewport, and user preferences. Native controls, fluid layouts, responsive images, container queries, cascade layers, and feature queries solve common problems without turning every change into a device-specific breakpoint.
Use the native HTML element for the job
Choose markup for what an element does, not merely how it looks. Use a button for an action and a link with an href for navigation. A native button is keyboard-operable without recreating interaction on a generic element.
<button type="button">Save changes</button>
<a href="/guides">Browse guides</a>
CSS can change their appearance without removing their built-in semantics and behavior. Keep interactive elements visually recognizable and retain a clear keyboard focus indicator; if you replace the browser’s default outline, provide an equally clear alternative. Styling a div to resemble a button does not make it behave like one. See MDN’s button reference and anchor reference.
Let content drive responsive layout
Flexbox and Grid can adapt naturally to available space, often avoiding a breakpoint for each screen size. For a card collection, Grid’s auto-fit and minmax() can create as many columns as fit while keeping each card above a useful minimum width.
#1 Best Overall
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
gap: 1rem;
}
img,
video {
max-inline-size: 100%;
}
The media rule prevents media from overflowing its containing inline space; it does not make an image larger than its intrinsic size. The logical property max-inline-size serves the same general role as max-width: 100% in common horizontal writing modes. MDN describes max-width: 100% as a way to scale images down to fit without enlarging them beyond their intrinsic size. See MDN’s responsive design guide.
Use media queries for viewport and environment changes
A media query responds to characteristics of the viewing environment, such as viewport dimensions or a user’s motion preference. Choose a breakpoint when the content or layout needs to change, rather than assigning breakpoints to named devices.
@media (width < 40rem) {
.site-nav {
/* Switch to a compact presentation when the layout needs it. */
}
}
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {
scroll-behavior: auto;
animation-duration: 0.01ms;
animation-iteration-count: 1;
transition-duration: 0.01ms;
}
}
Treat the motion declarations as an illustration, not a universal drop-in rule: review each animation and transition in the actual interface, and make sure the reduced-motion experience remains understandable. Media queries are useful when a viewport or environment condition is the reason for the change; for component width, a container query may be a better fit.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Use container queries for reusable components
A viewport breakpoint cannot tell whether a card sits in a wide main column or a narrow sidebar. A size container lets descendants respond to the space available in the component’s containing region, which is useful when the same component appears in differently sized areas.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →.article-slot {
container-type: inline-size;
}
.article-card {
display: grid;
gap: 1rem;
}
@container (width > 42rem) {
.article-card {
grid-template-columns: 12rem 1fr;
align-items: start;
}
}
container-type: inline-size establishes an inline-size query container. The @container rule applies to descendants of the nearest eligible container. Use container-type: size only when you need to query both dimensions: it applies broader containment, so understand that effect before choosing it. See MDN’s container queries guide and container-type reference.
Serve images appropriate to the rendered layout
A fluid-size rule handles overflow, but it does not by itself let the browser choose among image resolutions or crops. Use srcset and sizes when the browser should select an appropriate resource for the rendered slot; use picture when you need art direction, such as a different crop at a narrower layout.
Rank #3
<img
src="landscape-800.jpg"
srcset="landscape-400.jpg 400w, landscape-800.jpg 800w, landscape-1600.jpg 1600w"
sizes="(max-width: 40rem) 100vw, 50vw"
width="1600"
height="900"
alt="A developer reviewing a responsive page layout"
>
Make the width candidates and sizes expression match the actual layout; this pattern is not a guarantee of a performance improvement by itself. Give informative images alternative text that conveys their relevant content, and use empty alternative text for images that are purely decorative. See MDN’s responsive images guide.
Make stylesheet precedence explicit with cascade layers
When a project combines reset, vendor, base, component, and utility styles, cascade layers can establish which groups take priority without escalating selector specificity just to win. Declare the intended order deliberately, especially when third-party styles are involved.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches@layer reset, vendor, base, components, utilities;
@layer base {
body { margin: 0; }
}
@layer components {
.button { border-radius: 0.4rem; }
}
Layer order participates in the cascade, so it is worth planning before styles accumulate. When a rule does not appear to apply, browser developer tools can show matched declarations and which declarations were overridden. See MDN’s cascade layers reference.
Rank #4
Use feature queries for progressive enhancement
@supports tests whether the browser supports a CSS capability. Unlike a media query, it does not test viewport or device conditions. Keep a usable baseline outside the feature query, then add the enhancement inside it.
.card-list {
display: block;
}
@supports (display: grid) {
.card-list {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
gap: 1rem;
}
}
Check support for the specific feature you use and verify that the fallback remains acceptable. A feature query only gates the enhancement; it does not make an unsuitable fallback usable. See MDN’s @supports reference.
Choose the technique by what should trigger the change
| Technique | What drives the change | Good fit | Boundary |
|---|---|---|---|
| Flexbox or Grid | Available space and natural content layout | Layouts that can reflow without a special viewport rule | Use another technique when the change depends on the overall viewport, user preference, or a component’s own region. |
| Media query | Viewport or environment condition | Page-level changes or preferences such as reduced motion | It cannot distinguish two placements of the same component within one viewport. |
| Container query | Size of the nearest eligible container | A reusable component used in areas with different widths | Requires a declared query container; containment behavior depends on the chosen container-type. |
| Feature query | Browser support for a CSS capability | Enhancing a usable baseline with a newer feature | It checks support, not whether the fallback is well designed. |
Across these choices, preserve the HTML element’s intended semantics and keyboard behavior, and use cascade layers when stylesheet precedence needs clearer organization.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteBest Value
Or skip the browser setup
If you need a rendered page image while building or documenting a site, a screenshot API can handle the browser capture. ScreenshotNeo is a website screenshot API and MCP server for developers.
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 documentation for request options. It accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, or any MCP client. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up free for 1,000 screenshots a month, with no card required.
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.




