Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Progressive Enhancement – Feature Detec | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 27 of 55

·HTML

Progressive Enhancement – Feature Detection

8 min

Course progress49%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Baseline functionality for older browsers
  • Feature detection using `<picture>` (images) and `@supports` (CSS)
  • Avoiding JavaScript‑only solutions for core content
  • Using Modernizr and polyfills wisely
  • Testing progressive enhancement with browser devtools

Building for All Browsers

Progressive Enhancement starts with a baseline experience for the least capable browsers, then adds richer features when supported.

Example: Using <picture> for responsive images

<picture>
  <source srcset='hero.webp' type='image/webp' />
  <source srcset='hero.jpg' type='image/jpeg' />
  <img src='hero.jpg' alt='Hero image' loading='lazy' />
</picture>

Older browsers ignore <picture> and fall back to the <img> tag, ensuring the image still appears.

CSS feature detection with @supports

@supports (display: grid) {
  .grid { display: grid; }
}

If the browser doesn’t understand Grid, the rule is ignored and the layout gracefully degrades.

Tools

  • Modernizr – Detects a wide range of HTML5/CSS3 features and adds classes to <html>.
  • Polyfills – Provide fallback implementations for missing APIs (e.g., fetch, Promise).
  • <script type='module'> – Native modules load only in browsers that support them; older browsers fall back to a classic script.

Best‑practice workflow

  1. HTML first – Markup must be functional without any CSS or JS.
  2. CSS layer – Add layout and styling; use @supports for newer features.
  3. JavaScript enhancement – Add interactivity, checking for feature support before use.

Quick checklist for progressive enhancement

  1. Content usable without CSS/JS? ✅
  2. CSS fallbacks (@supports) in place for newer layout methods? ✅
  3. Feature‑detection scripts (Modernizr or custom) added? ✅
  4. Polyfills included only when needed? ✅
  5. No core functionality hidden behind a single‑browser API? ✅

Tip: Test your page in an older browser (e.g., IE 11) or use Chrome’s Network → Disable JavaScript to see the baseline experience.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonWeb Fonts – Google Fonts & @font-faceContinue to lesson 28Accessibility – ARIA Roles, Live Regions, and Keyboard NavigationBack to HTML Course curriculum