Skip to content
Skillpedia
Images & icons75k · #2979

picture-element

What it does

This skill reviews picture elements in a project and fixes ones that are missing their img fallback or key attributes. It is for web builders who serve images in modern formats.

When to use it

  • ✓When you ask the agent to check the picture elements in a project for missing fallbacks.
  • ✓When an image does not appear in some browsers and the picture markup may be incomplete.
  • ✓When you are adding modern image formats and want the markup to be correct from the start.

Skill link

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/picture-element/SKILL.md

Copy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.

How to use

The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.

Ready-to-paste message

Use this skill to help me: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/picture-element/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute →

Example of what to ask your AI

“Can you check the picture elements on my site and fix any that are missing a fallback image or alt text?”

5 new skills a week. 1 minute to read.

How it works

The agent checks that each picture element ends with an img element that has alt, width, and height attributes. It also checks that source elements come first, have a srcset or media value, and include a type for format choices. It then adds any missing pieces.

Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Use <picture> with an <img> fallback

A <picture> without an <img> fallback renders nothing in browsers that don't support <picture> (IE11) or don't support any of the <source> formats. The <img> child is also where alt, width, height, loading, and fetchpriority attributes live—these apply regardless of which source the browser selects.

Quick Reference

  • Every <picture> must end with an <img> element—it is the required fallback and carries alt
  • <source> elements are evaluated top-to-bottom; the first match wins
  • Use type="image/avif" and type="image/webp" on <source> for format selection
  • The <img src> should point to a JPEG or PNG—the universal fallback for all browsers

Check

Scan all <picture> elements in this codebase. Verify: 1) Every <picture> has an <img> as its last child (required fallback). 2) The <img> has an alt attribute. 3) The <img> has width and height attributes. 4) <source> elements appear before the <img> child. 5) Each <source> has either a srcset attribute or a media attribute. 6) format-selecting <source> elements have a type attribute (type="image/avif", type="image/webp"). Flag any <picture> missing an <img> child or with <img> not as the last child.

Fix

For each <picture> element with issues: 1) If missing <img>: add <img src="{fallback-url}" alt="{description}" width="{w}" height="{h}"> as the last child. 2) If <img> is not last: move it to after all <source> elements. 3) If <source> elements lack type attributes for format selection: add type="image/avif" or type="image/webp". 4) Verify the <img src> points to a universally supported format (JPEG or PNG) as the ultimate fallback. Show the corrected <picture> markup.

Explain

Explain how the <picture> element works. Browsers evaluate <source> elements in document order and use the first one whose conditions match (type, media, srcset). The <img> element is the fallback for browsers that don't support <picture> (IE11) or don't support the source format. Without an <img> child, <picture> is invalid HTML and produces no output. The alt attribute must be on the <img>, not the <source> elements—it applies regardless of which source is selected.

Code Review

Review image assets, markup, and delivery configuration related to Use <picture> with an <img> fallback. Flag exact files or components where format choice, sizing, or loading behavior violates the rule, and describe how to confirm the fix in DevTools.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/images/picture-element

FAQ

Why does the img fallback matter?

Browsers that do not support picture or the listed formats need the img element to show anything at all.

How do the source elements work?

The skill says they are checked from top to bottom, and the first match is used.

Where do the alt and size attributes go?

The skill says they belong on the img element, where they apply whichever source is picked.

Details

Original description by the author

Use when reviewing image assets, markup, and CDN or build transforms related to Use <picture> with an <img> fallback. Check encoded size, rendered size, loading strategy, and above-the-fold impact together.

repo: thedaviddias/Front-End-Checklist

Popularity

GitHub stars
75k
Ranking position
#2979
License
MIT
Updated
10/31/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills