All categories

Category

HTML

Semantics, forms, accessibility primitives, web components.

2 questions

2 of 2
HTML
Medium
What are semantic HTML elements and why do they matter?

Semantic elements describe meaning, not appearance: <header>, <nav>, <main>, <article>, <section>, <aside>, <footer>, <button>, <figure>, <time>. They give assistive tech landmarks, give browsers built-in keyboard and focus behavior, give SEO structured content signals, and make code self-documenting. Compare <div class='button'> (zero meaning) to <button> (focusable, click+keyboard, disabled state, form participation).

6 min
HTML
Easy
How does the srcset attribute work and when would you use it for responsive images?

srcset is an <img>/<source> attribute that lists multiple image candidates so the browser picks the best one for the device. Two forms: width descriptors ('img-400.jpg 400w, img-800.jpg 800w') paired with sizes for responsive widths, or pixel-density descriptors ('img.jpg 1x, img@2x.jpg 2x') for fixed-width retina. Saves bandwidth on small/low-DPR screens and serves crisp images on retina without shipping huge files to everyone.

6 min