Home / Guides / Free Icons for Websites: Inline SVG, CSS and Performance

Free Icons for Websites: Inline SVG, CSS and Performance

GUIDE · 5 MIN READ

Two ways to put an SVG on a page

A website can show an SVG icon in two ways. The first is an ordinary image tag pointing at the file: simple, cacheable, and perfectly fine for logos, illustrations and anywhere the icon never changes colour. The second is inline SVG — pasting the icon's code directly into your HTML. Inline icons cost a little markup, but they unlock the technique that makes stroke icons so pleasant to theme: once an icon's colour is set to the CSS keyword currentColor, CSS can reach inside it and change its colour live, including hover and focus states. For interface icons — buttons, toolbars, navigation — inline is almost always the right choice. For a big decorative graphic repeated across fifty pages, the image tag wins on caching alone.

The currentColor trick

The keyword currentColor means “whatever text colour surrounds me”, so an icon that uses it inside a button automatically matches the button's label. Set the button to your brand colour and the icon follows; change the button on hover and the icon changes too, with no extra CSS at all. It is the same behaviour as text, and it is why a whole interface can be re-themed by changing a handful of colour values instead of redrawing a single icon. One honest detail about Icondusk downloads: they do not arrive with currentColor. Every download comes with the colour you picked on the set page already baked in as a fixed hex value — open the file and you will see stroke="#e8490f" (or whichever colour you chose), not currentColor. That is deliberate: the file looks right the moment you drop it into any tool. If you want the icon to follow your CSS instead, it takes one small edit: change that stroke="#…" value to stroke="currentColor" — and do the same for the matching fill="#…" on the few icons that use small solid dots — then paste the code inline, and the icon follows your color property, hover states included.

CSS variables for the whole site

Go one step further and define your colours as CSS custom properties that components read. Change a value and every icon, button and highlight that reads it updates together. This site is built exactly that way, with one honest complication: there is no single --accent for all modes. The golden-hour palette lives in two separate :root blocks — one for light mode and one inside a prefers-color-scheme: dark query — and --accent itself changes between them, from #e8490f in light mode to #ff7a45 after dark, so it stays legible on both surfaces. Around it sit companion variables: --accent-dark for link text that needs a deeper tone in light mode, and --btn / --btn-hover for the primary button backgrounds. It is the same principle as a design-token system in a large product, at postcard scale — and it means a rebrand is an afternoon of editing variables, not a month of hunting through files.

Accessibility: label what matters, hide what doesn't

Most interface icons are decorative — a magnifier next to the word “Search” adds nothing a screen reader needs to announce twice. Mark those aria-hidden and let the visible text do the talking. The exception is the icon-only button: when an icon is the only content of a control, the control needs an accessible name, such as an aria-label of “Close” or “Download”. Also make sure the clickable area is a real button or link, at least 40 pixels in each dimension, so the icon works for touch and keyboard users alike — not a bare graphic with a click handler.

Dark mode and contrast

Once your icons use currentColor, dark mode is mostly a matter of choosing colours that survive both worlds. A recolour that looks great on a white card can vanish on a charcoal toolbar, and a pale icon that glows at midnight can wash out at noon. Test your chosen colour against your lightest and darkest surfaces, and keep a near-black and a near-white version of your scheme in your pocket for icons placed on photos and coloured banners. Icondusk's own palette keeps a warm ember accent that stays legible on both the cream light theme and the dusk-navy dark theme — steal that idea, even if you don't steal the colours.

Performance: small files, no icon fonts

A single Icondusk SVG weighs well under a kilobyte, and even forty of them add up to less than one mediocre photograph. Inline only the icons a page actually uses, or reference files so the browser can cache them across pages. Skip icon fonts: they render inconsistently, fail awkwardly when the font doesn't load, and are harder to make accessible. And never ship a 1024px PNG where a vector belongs — if the destination is a browser, the SVG is smaller, sharper and recolourable. For the full format comparison, see SVG vs PNG: which format should you download?

Every icon mentioned in our guides is free to download from the sets page — SVG and PNG, no attribution required.

Keep reading

More practical guides from the library.