Lesson 8 of 9
Responsive HTML Patterns
While CSS handles most responsive design, several HTML elements and attributes contribute to responsive behavior - <picture> for art direction, srcset for resolution switching, <meta viewport>, and responsive tables. Understanding HTML-level responsiveness is essential before layering CSS media queries.
HTML Responsive Features
- <meta name='viewport'> - WITHOUT this, mobile browsers render at 980px width then zoom out. Essential first step.
- <picture> element - Serve different images for different screen sizes (art direction).
- srcset attribute - Let browsers pick optimal image resolution: srcset='img-1x.jpg 1x, img-2x.jpg 2x'
- sizes attribute - Tell browsers image display size: sizes='(max-width: 768px) 100vw, 50vw'
- loading='lazy' - Native lazy loading. Only loads images/iframes when near viewport.
- Responsive tables - Use overflow-x:auto wrapper or restructure for mobile with data-label attributes.
- Responsive iframes - Use aspect-ratio CSS or padding-bottom trick for YouTube/Maps embeds.
Modern CSS layout techniques eliminate device-specific breakpoint bottlenecks
Try It Yourself: Custom Element
Line 9: Unknown tag <user> on line 9
Tip: "<user>" is not a valid HTML5 element. Use <div>, <span>, <p>, <section>, etc.
Line 9: Malformed tag: "</user-card>"
Tip: Tags must use valid HTML names and be properly formed. Example: <div>, <p class="text">
Line 10: Unknown tag <user> on line 10
Tip: "<user>" is not a valid HTML5 element. Use <div>, <span>, <p>, <section>, etc.
Line 10: Malformed tag: "</user-card>"
Tip: Tags must use valid HTML names and be properly formed. Example: <div>, <p class="text">
Line 11: Unknown tag <user> on line 11
Tip: "<user>" is not a valid HTML5 element. Use <div>, <span>, <p>, <section>, etc.
Line 11: Malformed tag: "</user-card>"
Tip: Tags must use valid HTML names and be properly formed. Example: <div>, <p class="text">
Line 12: Wrong closing tag: </div> found, expected </user> (line 12)
Tip: Close <user> (opened on line 11) with </user> before closing </div>.
Line 8: Unclosed <div> (opened on line 8)
Tip: Add </div> to properly close this element.
Line 9: Unclosed <user> (opened on line 9)
Tip: Add </user> to properly close this element.
Line 10: Unclosed <user> (opened on line 10)
Tip: Add </user> to properly close this element.
Line 11: Unclosed <user> (opened on line 11)
Tip: Add </user> to properly close this element.
Key Takeaways
- While CSS handles most responsive design, several HTML elements and attributes contribute to responsive behavior - <picture> for art direction, srcset for resolution switching, <meta viewport>, and responsive tables.
- <meta name='viewport'> - WITHOUT this, mobile browsers render at 980px width then zoom out. Essential first step.
- <picture> element - Serve different images for different screen sizes (art direction).
- srcset attribute - Let browsers pick optimal image resolution: srcset='img-1x.jpg 1x, img-2x.jpg 2x'
Finished this lesson?