Skip to main content

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.

10 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

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.
Diagram
Loading diagram…

Modern CSS layout techniques eliminate device-specific breakpoint bottlenecks

Try It Yourself: Custom Element

Try It Yourself: Custom ElementHTML⚠ 11 errors
⚠ Syntax Issues (11)
✕

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.

HTML
✕ 11 errors
HTML|39 lines|11 errors, 0 warnings
UTF-8

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'

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/9 done