Use when reviewing image assets, markup, and CDN or build transforms related to Use <figure> and <figcaption> for image captions. Check encoded size, rendered s
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-figure-figcaption-341d538a7246 ,按照其中的说明把「figure-figcaption」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Using a <p> tag as a caption is invisible to assistive technology as an image description. The <figure>/<figcaption> pattern creates a machine-readable relationship between an image and its caption, which screen readers surface to users. It also communicates to search engines that the caption describes the image, supporting image SEO.
<figure> with <figcaption> as a direct child<figcaption> must be the first or last child of <figure><figure> is appropriate for images, code blocks, diagrams, and charts—not every imageScan the codebase for images with adjacent visible text that acts as a caption (e.g., a
or immediately below an describing it). Verify: 1) Such image-caption pairs are wrapped in
. 2) The caption text is inside a element. 3) is a direct child of . 4) The alt text on the is not identical to the text—they serve different purposes. Flag any followed by descriptive text that is not structured as figure/figcaption.For each image with an adjacent caption: 1) Wrap the and its caption text in a
element. 2) Move the caption text into a element inside . 3) Review the alt attribute—if the figcaption already fully describes the image for sighted users, the alt can be shorter or empty (alt="") only if the figcaption alone is sufficient for screen readers too; otherwise keep a concise alt. 4) Position as the first or last child of . Show the corrected HTML.Explain the semantic meaning of
and . The element represents self-contained content (an image, code sample, diagram) that is referenced from the main content but could be moved without affecting the document flow. provides a caption or legend for the figure. Screen readers announce the figcaption in association with the figure, giving users context. Without this markup, sighted users see a caption but screen reader users hear only the alt text with no indication that a visible caption exists.Review image assets, markup, and delivery configuration related to Use
and for image captions. 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/en/rules/images/figure-figcaption