Objective. Students implement a mobile-first responsive design using CSS media queries, viewport meta tag, flexible units, and fluid images so a page displays correctly on at least three viewport sizes.
This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.
VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.
A responsive website adjusts its layout, typography, and images so it looks correct and functions well on any screen — from a 375 px smartphone to a 1280 px desktop monitor. Responsive design is not a single feature; it is a combination of the viewport meta tag, flexible units, fluid images, and CSS media queries working together.
Without the viewport meta tag, mobile browsers render a page at a desktop width and then scale it down, making text tiny and tap targets unreachable. Place this tag in the `<head>` of every page:
```html
<meta name="viewport" content="width=device-width, initial-scale=1">
```
`width=device-width` tells the browser to use the device's actual pixel width. `initial-scale=1` sets the default zoom to 100 %. This single line is the prerequisite for every other responsive technique.
Mobile-first means you write your base CSS for the narrowest screen first, then layer on styles for wider screens using `min-width` media queries. This approach is preferred because:
A mobile-first workflow looks like this:
```css
/ Base styles — applied to all screens, including phones /
body {
font-size: 1rem;
padding: 1rem;
}
/ Tablet and wider /
@media (min-width: 768px) {
body {
padding: 2rem;
}
}
/ Desktop and wider /
@media (min-width: 1280px) {
body {
max-width: 1200px;
margin: 0 auto;
}
}
```
When you refactor a desktop-only CSS file, remove fixed pixel widths from the base rules, replace them with flexible units, and move desktop-specific rules into a `min-width: 1280px` block. Comment every breakpoint decision so other developers understand your reasoning.
A media query is a conditional block that applies CSS only when a condition is true. The most common condition is viewport width:
```css
@media (min-width: 768px) {
/ rules here apply only at 768 px and wider /
}
```
Common breakpoints in industry practice are roughly 768 px (tablet) and 1280 px (desktop), though you should choose breakpoints where your content breaks, not based on specific device names. Document your reasoning in comments.
Avoid fixed pixel values for layout dimensions. Prefer:
Using these units means your layout stretches and compresses naturally without requiring a breakpoint for every small adjustment.
Images with a fixed pixel width overflow narrow viewports and break layouts. Apply these two rules to any image that should scale with its container:
```css
img {
max-width: 100%;
height: auto;
}
```
`max-width: 100%` prevents the image from exceeding its container. `height: auto` maintains the original aspect ratio. Apply this to hero images and any content image. Test at 375 px, 768 px, and 1280 px using Chrome DevTools Device Mode.
In Chrome, press F12 (or right-click → Inspect), then click the device-toolbar icon (a phone/tablet outline). You can type any pixel width into the dimension field. Use 375 px, 768 px, and 1280 px to match the three required breakpoints. Take screenshots at each size for your lab log. DevTools Device Mode simulates viewport dimensions; it does not emulate all aspects of real hardware, so treat it as a fast first check rather than a replacement for testing on real devices when possible.
Responsive design has direct accessibility consequences. Failing to meet these points means real users — including users with disabilities — cannot use your site:
Use the 15-point responsive checklist provided in the lab to audit your own page and a classmate's. The pass mark for the instructor audit is 13 of 15 checklist items passing across all three viewports (375 px, 768 px, and 1280 px). Treat a failed item as a bug, not a style preference — document it in your written summary with a specific fix recommendation.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.