# Alt Text and Headings reference: Alternative Text -- The Rules Part of the `alt-text-headings` skill. Read this only when the task reaches these sections. ## Alternative Text -- The Rules ### Rule 1: Every `` Gets an `alt` Attribute No exceptions. The question is what goes in it. ```html The engineering team at the 2025 company retreat, standing in front of the main office Your profile ``` ### Rule 2: Describe Content, Not Appearance ```html A blue bar chart with 5 bars Quarterly revenue: Q1 $2M, Q2 $2.5M, Q3 $3.1M, Q4 $3.8M, Q5 $4.2M

Our CEO

Photo of our CEO

Our CEO

Sarah Chen speaking at the 2025 developer conference ``` ### Rule 3: Functional Images Describe the Action When an image is inside a link or button, the alt text describes where it goes or what it does, not what the image looks like. ```html Acme Corp home page Acme Corp on Twitter ``` ### Rule 4: Decorative Images Are Hidden Images that add no information -- visual flourishes, spacers, backgrounds, dividers: ```html ``` Both `alt=""` and `role="presentation"` work. Use `alt=""` as the primary method; on an `img` it already removes the image from the accessibility tree, so `aria-hidden="true"` adds nothing there. Use `aria-hidden="true"` for decorative inline SVGs and other decorative elements that have no `alt`. ### Rule 5: Complex Images Need Long Descriptions For charts, diagrams, infographics, and data visualizations that cannot be adequately described in a short alt text: ```html
Company organizational chart. Full description below.
Full description of organizational chart

The CEO reports to the board. Three VPs report to the CEO: VP Engineering (5 teams, 47 people), VP Product (3 teams, 18 people), VP Marketing (4 teams, 22 people)...

User registration flow
Step 1: User enters email. Step 2: System checks if email exists. If yes, show login prompt. If no, proceed to step 3...
``` ## SVG Accessibility ### Inline SVGs ```html Monthly Sales Bar chart showing sales increasing from $10K in January to $45K in June ``` Requirements for meaningful SVGs: - `role="img"` on the `` element - `` element as the first child (acts as the accessible name) - `` element for longer descriptions - `aria-labelledby` referencing both title and desc IDs - Do NOT add `focusable="false"` on meaningful SVGs Requirements for decorative SVGs: - `aria-hidden="true"` on the `` element - `focusable="false"` to prevent focus in Internet Explorer and legacy (pre-Chromium) Edge; harmless elsewhere - No `` or `` elements ### SVGs in Buttons and Links ```html ``` Never give the SVG an accessible name AND label the parent button/link -- that creates double announcements.