HTML

html/project-icons

Icons use the project's generated icon classes (its icon classes), not separate SVG image files.

minorstaticfe-images

Inside a project, the report and explain replace the example in braces with your project's own helper.

Why

This project builds its icons into CSS classes ({{icon-classes.tool|an icon build step}}), so one cached file serves every icon and they share size and colour rules. An <img src="…/icons/x.svg"> bypasses that build: another request per icon, an icon that does not follow the text colour, and a second way to do the same thing. The rule runs only in projects where such a build was detected.

Fix

Use the generated class: <i class="icon-<name>" aria-hidden="true"></i> and give the control a text label (visible, or aria-label on the button). A new icon is added as an SVG in the icon source folder and the build is run again.

Examples

<!-- bad -->
<button type="button"><img src="/assets/icons/close.svg" alt="Close"></button>
<!-- good -->
<button type="button" aria-label="Close"><i class="icon-close" aria-hidden="true"></i></button>

Sources

Facts

Id
html/project-icons
Severity
minor
Check
static checked in the source by audit
Applies to
html angular vue svelte astro jsx
Needs the project helper
icon-classes
Taught by the skill
fe-images Images and media delivery
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain html/project-icons