Ask ten frontend developers for the best way to render icons in a modern web UI, and you'll get ten different, equally frustrated answers.
Inline SVGs? They bloat your HTML with megabytes of repeated <path> tags, clutter the DOM, and bypass browser caching. SVG sprites? They rely on clunky <svg><use href="#icon"/></svg> markup and make isolated styling awkward. Icon fonts? They break on flaky networks and cause screen readers to read Unicode characters as gibberish.
Web standards researcher Lea Verou recently published a landmark article and the @nudeui/icons library, proposing an elegant alternative: moving your entire icon system into CSS.
Design Tokens and Masking with mask-image
The technique builds on the standardized mask-image property—now part of Baseline across all modern browsers—paired with CSS Custom Properties.
All vector graphics leave your HTML and live once as global tokens in :root. UI components contain zero SVG tags. Instead, a ::before pseudo-element renders the icon using currentColor, clipped by a CSS mask:
/* 1. Global registration of icon tokens */
:root {
--icon-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 6h18m-2 0v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2'/%3E%3C/svg%3E");
--icon-edit: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'/%3E%3C/svg%3E");
}
/* 2. Base button class */
.btn-icon {
display: inline-flex;
align-items: center;
gap: 0.5em;
}
.btn-icon::before {
content: "";
display: inline-block;
width: 1em;
height: 1em;
background-color: currentColor;
-webkit-mask: var(--icon) no-repeat center / contain;
mask: var(--icon) no-repeat center / contain;
}
/* 3. Assigning a specific icon */
.btn-delete {
--icon: var(--icon-trash);
}
Your button markup in HTML becomes remarkably clean:
<!-- Clean HTML without a single SVG tag inside the button -->
<button class="btn-icon btn-delete">Удалить запись</button>
Scaling, Themes, and Container Style Queries
What does this give a real design system?
- Automatic color inheritance: Because the icon uses
currentColor, changing button colors on hover, focus, or dark mode updates the icon automatically with no extra rules. - Proportional scaling: Sizing is locked to
1em. Bump up a heading's font size, and its icon scales right along with the text. - Style Query reactivity: Using modern
@container style(--variant: warning)queries, you can swap icons inside a card based on theme or parent state without touching the DOM in JavaScript. We covered these styling queries in Detecting Element Overlap with Pure CSS: Anchor Positioning and Style Queries.
Accessibility (a11y) Checklist for CSS Icons
- Icon-only buttons without visible text include an
aria-label="Action description"attribute - Masked
::beforepseudo-elements keepcontentempty so screen readers don't announce them - Visual rendering is verified in Windows High Contrast mode
Lea Verou's methodology shows how modern CSS can strip away piles of markup noise and bring elegance back to HTML.

![Node.JS [ru]](/api/digests/it_development/daily/20261017/assets/sources/we-use-js.jpg?v=c0e73553e6eb6a7d832be97bcd3f1ecdae4ce271021d2683f468d654debdc973)

