How to Use Icons in Markdown - A Simple Guide
Icons are a great way to enhance your Markdown documents. They make your content engaging and visually appealing, and can also help to convey meanings more efficiently. In this tutorial, we will walk you through how to use icons in Markdown.
Markup for Icons
Markdown doesn’t support icons out of the box. However, we can leverage web-based icon libraries like FontAwesome or Material Icons to add icons in Markdown.
To use icons from these libraries, you’ll have to use HTML tags within your Markdown. While this is not pure Markdown anymore, it’s important to note that most Markdown parsers, like the ones on GitHub, support a subset of HTML.
Here is the basic syntax for adding a FontAwesome icon:
<i class="fab fa-github"></i>
And for Material Icons:
<i class="material-icons">face</i>
The string after fa-
or inside material-icons
signifies the specific icon to use.
Icons in Headers and Button Links
You can add icons to headers and hyperlink buttons for unique navigation elements.
## <i class="fas fa-cog"></i> Configuration
[Visit Blog <i class="fas fa-external-link-alt"></i>](https://blog.markdowntools.com/)
Icons and Lists
Incorporate icons in your lists to signify different item statuses or categories:
- <i class="fas fa-check"></i> Finished Items
- <i class="fas fa-times"></i> Unfinished Items
- <i class="fas fa-inbox"></i> Unassigned Items
Using Emojis
Apart from using external libraries, you can use emojis to inject small, colorful, and appealing icons into your Markdown. Since emojis are unicode symbols, they can be inserted right into the text without needing to leverage embedded HTML:
- :white_check_mark: Finished Items
- :x: Unfinished Items
- :inbox_tray: Unassigned Items
The standard for using emojis in Markdown is to wrap the emoji’s alias in colons. Visit the Emojipedia for a vast list of available emojis.
Please note, emojis rendering might differ based on the browser and platform.
Pitfalls and Caveats
Remember, Markdown parsers might strip out or misinterpret the <i>
tag, so we always recommend previewing the content before publishing it. Check out our guide on How to Preview Rendered Markdown in Vim to quickly view your rendered markdown during editing.
Also, if you use Jekyll or other static site generators, make sure your Markdown engine is set to kramdown
, redcarpet
, or something similar that supports parsing inline HTML.
Conclusion
Using icons in Markdown is straightforward, but you should always verify how they appear in your specific Markdown renderer. Whether you’re adding icons for an intuitive UI or expressive emojis for lively content, Markdown, combined with HTML, gives you flexibility and power to enhance your content and delight your readers.