Custom Styles in GitHub Readme Files

GitHub readme files — usually ./readme.md — are Markdown, and Markdown does allow HTML. Even so, you can't drop <style> or <script> tags into them: the tags are stripped, so your custom styling never lands. Or so it seems.

There is a route around that limitation:

  1. An SVG can be embedded as an <img src="./file.svg" alt="" />, and that works anywhere.
  2. When an SVG is used this way, even animations inside it play.
  3. SVG provides <text> for textual content, and <foreignObject> for ordinary HTML content.
  4. SVG supports <style> tags.
  5. Your readme.md file does support <img> elements pointed at SVG sources.

Sindre Sorhus put all of those pieces together in an example.

The same SVG source also works here: