Responsive HTML Testing
Test desktop, tablet, and mobile layouts with preview width controls and media-query checks.
Steps
- Build the layout at desktop width first.
- Switch to tablet and mobile preview widths.
- Adjust CSS with media queries.
- Recheck interactive elements at each width.
- Validate that text remains readable without horizontal page scroll.
Example
HTML
<main class="cards"><article>A</article><article>B</article><article>C</article></main>
CSS
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cards article { padding: 24px; background: #dbeafe; }
@media (max-width: 600px) { .cards { grid-template-columns: 1fr; } }
JavaScript
console.log("Preview width:", window.innerWidth);
Run the sample, then switch preview widths. Above 600px the cards use three columns; at 600px or below they stack. The media query uses the iframe viewport width. Check long words, images, keyboard focus and tap targets as well as column layout. Width simulation does not reproduce every physical device or browser.
Tip
The viewport label shows the current preview frame width so you can align tests with common breakpoints.