Emojis As Favicons

By Mike Hadlow, published May 9, 2024

I’m no designer, and I like to keep things simple and easy to configure. So for the various websites I create I like to have an easy way to create a favicon icon. To do this I use a reusable snippet of SVG that I can customize to have a different color and characters for each site. Here is the SVG for the favicon for this site:

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <rect width="100" height="100" fill="none" rx="15" />
  <g transform="translate(0, 30)" fill="white" font-size="60" font-family="sans-serif">
    <text x="0" y="40">✅</text>
  </g>
</svg>

You can customize it for your own site by just replacing the tokens below:

<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <rect width="100" height="100" fill="{{ back color here }}" rx="15" />
  <g transform="translate(0, 30)" fill="{{ front color here }}" font-size="60" font-family="sans-serif">
    <text x="0" y="40">{{ one or two chars here }}</text>
  </g>
</svg>

And of course those characters can be emojis 👍🏻

Don’t forget the <link> element in your <header>:

<link rel="icon" href="/favicon.svg" type="image/svg+xml">

Hi, I’m Mike Hadlow. Software Engineer, based in Sussex, UK.

Find my old blog at Code Rant. This ran from 2005 to 2020 and has hundreds of posts.

All code on this blog is published under an MIT licence. You are free to copy it and use it for any purpose without attribution. There is no warranty whatsoever. All non-code text is copyright Mike Hadlow and cannot be reused without permission.

There are no cookies on this site

The GitHub repository for this site is here.