Course contentsShow
← Web Development
Lesson 1219 of 2,98222. Responsive Images and MediaFree lesson

The Default src as Fallback

Why you still need a src attribute and how it serves as the fallback for older browsers.

The Default src as Fallback

You'll learn why the src attribute remains essential even when using modern responsive image features.

The Safety Net for Older Browsers

When you use advanced responsive image features like srcset and sizes, you might wonder: "Do I still need the plain old src attribute?" The answer is a definite yes. The src attribute acts as your fallback for browsers that don't understand srcset and sizes.

Think of it like providing both a smartphone app and a website. Not everyone has the latest phone, so the website ensures everyone can still access your service. Similarly, src ensures everyone can see your image.

How It Works

Browsers that support srcset will intelligently choose from your provided image sources and ignore the src attribute. But older browsers that don't recognize srcset will simply use the src image—they'll skip over the attributes they don't understand and fall back to what they know.

<img 
  srcset="image-400.jpg 400w,
          image-800.jpg 800w,
          image-1200.jpg 1200w"
  sizes="(max-width: 600px) 400px, 800px"
  src="image-800.jpg"
  alt="A scenic landscape">

In this example, modern browsers pick from the srcset options. Older browsers display image-800.jpg from the src attribute—a reasonable middle-ground choice that works on most screens.

Choosing Your Fallback Image

Your src should point to a medium-sized version: not too large (penalizes older mobile browsers) and not too small (looks poor on desktop). Think of it as your "safe default."

Key Takeaway: Always include a src attribute with a sensible middle-ground image—it's your accessibility and backwards-compatibility guarantee for browsers that don't support responsive image features.