To reference an icon, you need to know two bits of information.
1) its name, prefixed with fa- (meaning “font
awesome” naturally!)
and 2) the style you want to use’s corresponding prefix**.
<i class="fas fa-camera" /i> <!-- this icon's 1) style prefix == fas and 2) icon name == camera -->
<i class="fas fa-camera" /i> <!-- using an ielement to reference the icon -->
<span class="fas fa-camera"> </span> <!-- using a >span< element to reference the icon
-->
Style Availability Style Prefix Example Rendering
Solid Free fas >i class=”fas fa-camera”<>/i<
Regular Pro Required far >i class=”far fa-camera”/i<
Light Pro Required fal >i class=”fal fa-camera”/i<
Duotone Pro Required fad >i class=”fad fa-camera”/i<
Brands Free fab >i class=”fab fa-font-awesome”/i<
The fa prefix has been deprecated in version 5. The new default is the fas solid style and the fab style for
brands.
Using CSS Pseudo-elements with Our SVG + JS Framework
https://fontawesome.com/how-to-use/on-the-web/advanced/css-pseudo-elements
https://codepen.io/fontawesome/pen/WVEobv
If you’re using our SVG + JS framework to render icons, you need to do a few extra things:
Enable Pseudo-elements
Using CSS Pseudo-elements to render icons is disabled by default when using our SVG + JS Framework. You’ll need to add the<script data-search-pseudo-elements ... >
attribute to the <script />
element that calls Font Awesome.
Set Pseudo-elements’ display to none
Since our JS will find each icon reference (using your pseudo-element styling) and insert an icon into your page’s DOM automatically, we’ll need to hide the real CSS-created pseudo-element that’s rendered.
pseudo-and-svg+js.html
<html>
<head>
<script data-search-pseudo-elements defer src="https://use.fontawesome.com/releases/latest/js/all.js" integrity="sha384-L469/ELG4Bg9sDQbl0hvjMq8pOcqFgkSpwhwnslzvVVGpDjYJ6wJJyYjvG3u8XW7" crossorigin="anonymous"></script>
<style>
.icon::before {
display: none;
}
.login::before {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f007";
}
.tps::before {
font-family: "Font Awesome 5 Free";
font-weight: 400;
content: "\f1ea";
}
</style>
</head>
<body>
<ul style="margin: 0;">
<li><span class="icon login"></span> Login</li>
<li><span class="icon tps"></span> TPS Reports</li>
</ul>
</body>
</html>
See it in Action!
We know this can be tough to get. Here’s a Codepen demo showing how to render icons via CSS Pseudo-elements with our SVG + JS Framework.
Using CSS Pseudo-elements with Uploaded Icons
You can add your uploaded icons to your designs using pseudo-elements, but you’ll need to take a couple of different steps.
Get the Unicode Value
Go to the Uploaded Icons page of your kit, open up the details of the icon you want to use, and copy the unicode value.
Reference the Unicode and Kit Font Family
Set the font to font-family: "Font Awesome Kit"
and use that unicode in your CSS along with the regular settings for using Font Awesome pseudo-elements, like this:
your.css
/* Step 1: Common Properties: All required to make icons render reliably */
.icon::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
/* Step 2: Reference Individual Icons */
.custom-icon::before {
font-family: "Font Awesome Kit";
content: "\e001"; /* change to your icon's unicode value */
/* font-weight isn't needed */
}
Support for Dynamic Changes
Let’s get a little cute with it by using some JavaScript and jQuery to toggle the class of an element.
<script>
setInterval(function () {
$('.ninety-four').toggleClass('arrow')
}, 1000)
</script>
<style>
.ninety-four::after {
margin-left: 0.25em;
font-size: 2em;
vertical-align: middle;
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f0c8";
}
.ninety-four.arrow::after {
content: "\f152";
}
</style>
<a class="ninety-four" href="https://en.wikipedia.org/wiki/Blink_element">Hey, do you remember the blink tag?</a>
https://fontawesome.com/how-to-use/on-the-web/setup/hosting-font-awesome-yourself
<!– using an element to reference the icon –>
<!– using a element to reference the icon –>
What’s in the Download?
The web-focused Font Awesome Package contains the following directories and files:
Files & Folders | What They Are | Where You Should Start |
---|---|---|
/css |
Stylesheets for Web Fonts | all.css |
/js |
SVG with JavaScript | all.js |
/less |
Less pre-processor | fontawesome.less |
/scss |
Sass pre-processor | fontawesome.scss |
/sprites |
SVG sprites | solid.svg |
/svgs |
Individual SVG for each icon | individual *.svg icons |
/webfonts |
Web Font files used with CSS | See /css |
Using Web Fonts with CSS
The /css/all.css
file contains the core styling plus all of the icon styles that you’ll need
when using Font Awesome. The /webfonts
folder contains all of the typeface files that the
above CSS references and depends on.
Copy the entire /webfonts
folder and the /css/all.css
into your project’s
static assets directory (or where ever you prefer to keep front end assets or vendor stuff).
Add a reference to the copied /css/all.css
file into the <head>
of each
template or page that you want to use Font Awesome on.
page.html
<head>
<link href="/your-path-to-fontawesome/css/all.css" rel="stylesheet"> <!--load all styles -->
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="far fa-user"></i> <!-- uses regular style -->
<i class="fal fa-user"></i> <!-- uses light style -->
<!--brand icon-->
<i class="fab fa-github-square"></i> <!-- uses brands style -->
</body>
Using a CSS Pre-Processor?
Using the /scss
or /less
versions of Font Awesome we’ve bundled in the
download? Check out our Sass
and Less docs for details on
their contents. Once you’ve compiled them into CSS, you can follow the CSS-focused steps noted here to
handle hosting and referencing icons.
Using SVG with JavaScript
The /js/all.js
loads all of the base features, plus all of the icon styles that you’ll need
when using Font Awesome. Copy it into your project’s static assets directory (or where ever you prefer
to keep front end assets or vendor stuff).
Add a reference to the copied /js/all.js
file within the <head>
of each
template or page that you want to use Font Awesome on.
template.html
<head>
<script defer src="/your-path-to-fontawesome/js/all.js"></script> <!--load all styles -->
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="far fa-user"></i> <!-- uses regular style -->
<i class="fal fa-user"></i> <!-- uses light style -->
<!--brand icon-->
<i class="fab fa-github-square"></i> <!-- uses brands style -->
</body>
Double-Check Your Paths
Since you’re managing all of the downloaded files yourself, make sure the references in your pages’
<head>
are accurate with where you’ve moved all of Font Awesome’s files in your
project.
Using Just Certain Styles
Want to use just certain styles of icons when using our Web Fonts with CSS framework?
The /css
folder contains the core styling and additional files for all of Font Awesome’s
style options – solid, regular, light, and brands. The /webfonts
folder contains
all of the typeface files that the above CSS references and depends on.
Icon Style | Web Font Filename | CSS Filename | Availability |
---|---|---|---|
Font Awesome Brands |
fa-brands-400.* |
brands.css |
Free |
Font Awesome Solid |
fa-solid-900.* |
solid.css |
Free |
Font Awesome Regular |
fa-regular-400.* |
regular.css |
Pro only |
Font Awesome Light |
fa-light-300.* |
light.css |
Pro only |
Copy both the /webfonts
and the /css
folders into your project’s static assets
directory (or where ever you prefer to keep front end assets or vendor stuff). You can remove any
styles’ .css
and web font files you don’t plan on using if you’d like.
Add a reference to the core styling file (/css/fontawesome.css
) and the CSS for individual
styles (e.g. /css/brands.css
) into the <head>
of each template or page
that you want to use Font Awesome on. Pay attention to the pathing of your project and where you moved
the files to in the previous step.
using-certain-styles.html
<head>
<!-- Our project just needs Font Awesome Solid + Brands -->
<link href="/your-path-to-fontawesome/css/fontawesome.css" rel="stylesheet">
<link href="/your-path-to-fontawesome/css/brands.css" rel="stylesheet">
<link href="/your-path-to-fontawesome/css/solid.css" rel="stylesheet">
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="fab fa-github-square"></i> <!-- uses brand style -->
</body>
Mind the Paths in Web Fonts
We recommend keeping the /webfonts
and /css
folders in the same directory. If
you don’t, you’ll need to change the path to the web fonts mentioned in each style’s CSS file.
Want use only certain styles when using our SVG with JS framework? The /js
folder contains the core styling and additional files for all of Font Awesome’s style options – solid, regular, light, and brands.
Icon Style | JS Filename | Availability |
---|---|---|
Font Awesome Brands |
brands.js |
Free |
Font Awesome Solid |
solid.js |
Free |
Font Awesome Regular |
regular.js |
Pro only |
Font Awesome Light |
light.js |
Pro only |
Copy the fontawesome.js
loader and whatever icon styles’ .js
files you’d like
to use into your project’s static assets directory (or where ever you prefer to keep front end assets or
vendor stuff). We recommend referencing the fontawesome.js
loader last.
using-certain-styles.html
<head>
<!-- Our project just needs Font Awesome Solid + Brands -->
<script defer src="/your-path-to-fontawesome/js/brands.js"></script>
<script defer src="/your-path-to-fontawesome/js/solid.js"></script>
<script defer src="/your-path-to-fontawesome/js/fontawesome.js"></script>
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="fab fa-github-square"></i> <!-- uses brand style -->
</body>
Double-Check Your Paths
Since you’re managing all of the downloaded files yourself, make sure the references in your pages’
<head>
are accurate with where you’ve moved all of Font Awesome’s files in your
project.
Next Steps
With the references complete, you can now start referencing
icons in your templates or pages’ <body>
and then check out all of the styling support we
pack into those supporting files you’ve loaded.
https://fontawesome.com/how-to-use/on-the-web/using-with/wordpress
WordPress
Font Awesome and WordPress – two great tastes that can go great together! Especially now that we have the
official Font Awesome WordPress plugin to make it easy.
Our official plugin lets you use Font Awesome the way you want. Use Pro or Free icons. Leverage the latest
release or a specific version of our icons. Choose the tech, either SVG or Web Font. Take your pick of loading
your icons from our classic Font Awesome CDN, or use Font Awesome kits – the easiest and most robust way to use
our icons on the web. And, if you haven’t had the chance to update your project in a long while, you can turn on
automatic compatibility for Font Awesome Version 4. But that’s not all… our official plugin can troubleshoot and
help you resolve when multiple versions of Font Awesome are loading on your site from other plugins/themes and
causing display or technical issues.
How can you get all this wonderful
stuff?
Just head on over to the Font Awesome plugin page on
WordPress.org or install it directly via your WordPress plugins admin page.
Our release candidate may have
some wet cement
Our plugin is still in pre-release mode and needs your feedback! If you have problems or questions, email us a hello@fontawesome.com.
Using the Font Awesome CDN (default)
By default, our plugin is set to serve Font Awesome Free Icons as a Web Font
via the Font Awesome CDN. You can change any of these settings directly in the plugin’s
settings.
Using Pro icons with the CDN
To use Pro icons with the CDN, you need to add your site’s domain to the allowed domains on your Font Awesome CDN page. Once you add your domain(s) and save
your plugin settings with Pro icons selected, your Pro icons will start showing up on your site right away.
Using a Kit
You’d be wicked smaht to use a kit with your WordPress set up! Just a few steps will get you going:
- If you don’t already have a kit set up, create a new one. You can
edit the icons, technology, version, and other settings right on that kit’s settings page. - Head to your account page to generate and copy your API
Token. - Return to the Font Awesome WordPress plugin settings page on your site. Select Use a Kit, and then paste
your API token into the field. Save those changes. - Pick a kit from the list. You’ll see the settings for the kit you’ve chosen listed below so you can
double-check that it’s set up the way you want. Make your selected kit active in your project by saving your
settings.
Changing your kit settings
Your kit settings are all managed on Font Awesome so if you need to make changes to the kit settings, head to
your kit settings page on FontAwesome.com, make and save your
changes, then hit the Refresh Kits Data button in the plugin.
Adjusting Settings
Free vs Pro
With this plugin, you can use any of the Font Awesome free icons with no additional set-up, and now you can
easily enable Pro icons as well. If you’re using CDN, select “Pro” and add your domain to your CDN settings. If you’re using a Kit, select “Pro” when you
set up the kit, then add your API Token and enable the
kit in WordPress, and your Pro icons will just work. Ta-da!
SVG vs Web Font
SVG allows you to do all kinds of fancy things with your icons that you can’t do with Web Font – like Power Transforms, Masks, and Layering – but doesn’t work as
well with pseudo-elements (learn more about
using pseudo-elements).
Versions
Your best option for versions is to select latest
– it gives you the newest icons and capabilities,
but if you need a particular previous version for some reason, you can pick it from the list. When a new version
of Font Awesome is released, you can update your settings to match. (Bonus! If you select latest
with kits, you always get the newest version.)
Version 4 compatibility
If you haven’t had a chance to update the icon names in your HTML to Font Awesome 5, you can turn this setting
on and we will automatically handle any references to old names and aliases
from Font Awesome 4.
Adding icons to your pages and posts
Once you’ve set up your plugin, you add icons to your pages and posts by using their names in shortcodes or
HTML.
When you use shortcodes, you add the name of the icon and a prefix, where the prefix is the style of
icon you want to use. Note that you don’t need to include the fa-
part of the name. And if
you don’t include any prefix, the style will default to Solid. The shortcode for an icon looks like this:
[icon name="coffee" prefix="far"]
Example using WordPress shortcode
Or you can use basic HTML with standard Font Awesome
syntax:
<i class="fas fa-coffee"></i>
Example using HTML
Make ’em Fancy Icons
Whether you use HTML or shortcodes, you can add CSS classes to make your icons extra fancy with all the features
that Font Awesome offers, like resizing, rotating, stacking, and more.
Troubleshooting with the Plugin
Font Awesome icons are popular – just like chocolate! – so lots of themes and plugins also load Font Awesome.
Sometimes the version of Font Awesome they use can conflict with yours. So we created a way to help you find and
prevent those conflicting versions from affecting your icons: The Conflict Detection Scanner.
If the official Font Awesome plugin seems to be set up correctly, but your icons still aren’t loading and you’re
not sure why, head over to the Troubleshoot tab. This has two parts: Detect Conflicts with Other
Versions of Font Awesome, and Versions of Font Awesome Active on Your Site.
Detect Conflicts with Other Versions of Font Awesome and the Conflict Scanner
This section lets you enable the conflict scanner tool that looks for any version of Font Awesome loading on
your site. Once you click the button to enable the scanner, a blue scanner box will appear in the lower right
corner of your browser window, like this:
Conflict detector shows in the bottom right of your browser for 10 minutes
It will run in the corner (but only be visible to admins) while you visit any page or area of your site that is
having trouble loading icons correctly. As you browse, it will scan and let you know if it finds other versions
of Font Awesome, and save them to the lower part of the Troubleshoot tab. Once you’re done, you can view the
results in the section below.
Versions of Font Awesome Active on Your Site
The upper area of this section shows any registered themes or plugins using Font Awesome. These have opted to
show you what settings they prefer and you can adjust your plugin settings to align. If you have multiple
plugins that have different needs, you can decide which is more important to align with.
The lower area lists any other versions of Font Awesome that may be loading on your site – these are the results
from the conflict scanner. If the scanner finds a potential conflict, it adds it here and you can choose to
block it from loading that other version of Font Awesome. Since we can’t tell who or what is loading those other
versions, we provided a little information that may help you figure it out: the type of resource and the URL
that is loading Font Awesome. The results will remain there until you clear it, even if you remove the plugin or
theme that generated it. If you think you’ve removed a plugin or theme that was creating a conflict, you can
clear that result and see if it pops up again. Or you can clear them all and start fresh anytime. Remember to
save after you clear or block an item.
Conflicts in the CDN or Kit Settings
If a plugin or theme has registered preferred settings and you are changing the settings to something different,
you’ll see a warning message about which plugin or theme might have issues with the new settings, like this:
A settings conflict will warn if you select different settings than a plugin is expecting
You can still save the conflicting settings but the plugin or theme may not work as expected. You can also visit
the Troubleshoot tab to see what settings the plugin(s) or theme(s) prefer – the differences with your settings
will be highlighted.
Tips
Generating an API Token Font Awesome kits use an API Token to securely get your kits in WordPress
without needing to share your Font Awesome credentials with your WordPress server. If your token ever gets
compromised, you can easily generate a new one on your Font Awesome Account page.
Using Pseudo-elements
CSS pseudo-elements are
a way to add icons before or after content in the HTML without editing the HTML, like adding a caret next to
drop-down menu item or an arrow next to an external link. Some plugins or themes rely on pseudo-elements – If
you disable them, be sure to check your site for missing icons.
You should avoid using SVG with pseudo-elements if possible. In fact, for performance reasons we don’t have the
SVG-with-pseudo-elements option when using a kit. You can enable pseudo-elements with SVG when using the CDN,
but know that it can cause your site to be very slow in some situations. Be sure to check your pages –
especially ones with lots of icons – after enabling pseudo-elements with SVG to verify that they aren’t loading
significantly slower.
Pseudo-elements are enabled by default with Web Font (in both kits and CDN) since they don’t impact performance
with that technology.
Manually
Adding Font Awesome to Your WordPress System (Advanced)
Negative, Ghostrider, the pattern is
full.
You might want to avoid this method unless you’ve got tons of experience with WordPress, have no other choice, or
are flying with Goose as your wingman.
You can add Font Awesome into the files of your WordPress system if you are an advanced user who doesn’t have
conflicts with other versions of Font Awesome from other themes or plugins, is comfortable modifying the
WordPress functions.php
file, or can’t install the Font Awesome plugin for some reason. Learn more about
advanced integration into WordPress.
For Plugin and Theme Developers
Help us help you! Use our official plugin as a composer package to include Font Awesome icons in your plugin or
theme development the right way and keep your plugin or theme – and your users’ sites – running at their best.
Learn more on how to do that in the plugin’s
GitHub repo.
https://fontawesome.com/how-to-use/on-the-web/other-topics/troubleshooting
Basic Use
You can place Font Awesome icons just about anywhere using a style prefix and the icon’s name. We’ve tried to
make it so that icons take on the characteristics and appear alongside text naturally.
Font Awesome is designed to be used with inline elements, and we recommend sticking with a consistent HTML
element to reference them by in your project. We like the <i>
tag for brevity and because
most folks use <em></em>
for emphasized/italicized semantic text these days. If that’s
not your cup of tea, using a <span>
is more semantically correct.
To reference an icon, you need to know two bits of information. 1) its name, prefixed with
fa-
(meaning “font awesome” naturally!) and 2) the style you want to use’s
corresponding prefix**.
<i class="fas fa-camera"></i> <!-- this icon's 1) style prefix == fas and 2) icon name == camera -->
<i class="fas fa-camera"></i> <!-- using an <i> element to reference the icon -->
<span class="fas fa-camera"></span> <!-- using a <span> element to reference the icon -->
Style | Availability | Style Prefix | Example | Rendering |
---|---|---|---|---|
Solid | Free | fas |
<i class="fas fa-camera"></i> |
|
Regular | Pro Required | far |
<i class="far fa-camera"></i> |
|
Light | Pro Required | fal |
<i class="fal fa-camera"></i> |
|
Duotone | Pro Required | fad |
<i class="fad fa-camera"></i> |
|
Brands | Free | fab |
<i class="fab fa-font-awesome"></i> |
The fa
prefix has been deprecated in version 5. The new default is the fas
solid style
and the fab
style for brands.
Since Font Awesome was first implemented and continues to support being rendered using the CSS
@font-face
method, each of its styles corresponds to a particular font weight:
Style | Availability | @font-face weight |
---|---|---|
Solid | Free Plan | 900 |
Regular | Pro Plan Required | 400 |
Light | Pro Plan Required | 300 |
Duotone | Pro Plan Required | 900 |
Brands | Free Plan | 400 |
Why would I need font-weight values?
While using an <i>
or other HTML element is the most popular and easy way to render an icon,
we do have advanced ways of using custom written CSS pseudo-elements if
you prefer to have extra markup. Font weights are used with that technique and are how you would set the icon’s
style.
Ligature use in Font Awesome on the
web
While our desktop workflow takes advantage of ligatures to make inserting icons into your favorite design and
presentation apps easy. As well as our SVG + JS framework, ligature lookup tables take up additional file space
and can cause performance issues. Until we have options and solutions for subsetting icons, we aren’t
comfortable considering ligatures for Web Fonts + CSS.
Font Awesome Icons + Your Project’s
Styling
Font Awesome icons automatically inherit CSS size and color (as seen in the examples below). This means they
blend in with text inline wherever you put them. Font Awesome tries not to be too opinionated, and sets just the
basic styling rules icons needed to render properly in context.
<span style="font-size: 3em; color: Tomato;">
<i class="fas fa-camera"></i>
</span>
<span style="font-size: 48px; color: Dodgerblue;">
<i class="fas fa-camera"></i>
</span>
<span style="font-size: 3rem;">
<span style="color: Mediumslateblue;">
<i class="fas fa-camera"></i>
</span>
</span>
Additional Styling Options
While the basic way to reference an icon is simple and hopefully straight-forward, we’ve provided support-level
styling for things like sizing
icons, aligning
and listing icons, as well
as rotating and transforming icons.
You can also add your own custom styling to Font Awesome icons by adding your own CSS rules in your project’s
code. Everything you can normally control with CSS is up for grabs – from color to display to alignment.
We recommend targeting icons in your CSS in couple of different ways.
Styling Case | Recommended Selector |
---|---|
Custom styling all icons | Add a consistent custom class to all icons (e.g. .icon ,.[projectprefix]-icon , or .fa-icon ) You can also use style classesthat match your in-use icon styles .fas { ... } .far { ... } .fal { ... } .fad { ... } .fab { ... } |
Custom styling a specific icon | Use the individual icon name, prefixed with .fa- .fa-user { ... } .fa-font-awesome { ... } |
Here’s a quick example of using those selectors to add custom color to Font Awesome icons:
adding-custom-styles.html
<head>
<!-- reference your copy Font Awesome here (from our CDN or by hosting yourself) -->
<link href="/your-path-to-fontawesome/css/fontawesome.css" rel="stylesheet">
<link href="/your-path-to-fontawesome/css/brands.css" rel="stylesheet">
<link href="/your-path-to-fontawesome/css/solid.css" rel="stylesheet">
<!-- custom styling for all icons -->
i.fas,
i.fab {
border: 1px solid red;
}
<!-- custom styling for specific icons -->
.fa-fish {
color: salmon;
}
.fa-frog {
color: green;
}
.fa-user-ninja.vanished {
opacity: 0.0;
}
.fa-facebook {
color: rgb(59, 91, 152);
}
</head>
<body>
<i class="fas fa-fish"></i>
<i class="fas fa-frog"></i>
<i class="fas fa-user-ninja vanished"></i>
<i class="fab fa-facebook"></i>
</body>
Writing Custom CSS with our SVG
+ JS framework
When using our SVG framework, remember that Font Awesome-based <i>
DOM elements are replaced
with new <svg>
elements by default. Be sure that your css rules target the right elements.
Sizing Icons
Both our Web Fonts + CSS and SVG + JS frameworks include some basic controls for sizing icons in the context
of your page’s UI.
Relative sizing
Icons inherit the font-size
of their parent container which allow them to match any text you might
use with them. With the following classes, we can increase or decrease the size of icons relative to that
inherited font-size
.
<i class="fas fa-camera fa-xs"></i>
<i class="fas fa-camera fa-sm"></i>
<i class="fas fa-camera fa-lg"></i>
<i class="fas fa-camera fa-2x"></i>
<i class="fas fa-camera fa-3x"></i>
<i class="fas fa-camera fa-5x"></i>
<i class="fas fa-camera fa-7x"></i>
<i class="fas fa-camera fa-10x"></i>
Here are a few more examples where you can see the relative scale.
<div style="font-size: 0.5rem;">
<i class="fas fa-camera fa-xs"></i>
<i class="fas fa-camera fa-sm"></i>
<i class="fas fa-camera fa-lg"></i>
<i class="fas fa-camera fa-2x"></i>
<i class="fas fa-camera fa-3x"></i>
<i class="fas fa-camera fa-5x"></i>
<i class="fas fa-camera fa-7x"></i>
<i class="fas fa-camera fa-10x"></i>
</div>
<div style="font-size: 24px;">
<i class="fas fa-camera fa-xs"></i>
<i class="fas fa-camera fa-sm"></i>
<i class="fas fa-camera fa-lg"></i>
<i class="fas fa-camera fa-2x"></i>
<i class="fas fa-camera fa-3x"></i>
<i class="fas fa-camera fa-5x"></i>
<i class="fas fa-camera fa-7x"></i>
<i class="fas fa-camera fa-10x"></i>
</div>
Did You Know?
You can also directly style an icon’s size by setting a font-size
in your project’s CSS that targets
an icon or directly in the style
attribute of the HTML element referencing an icon.
Sizing Scale Details
Class | Size | Other Notes |
---|---|---|
fa-xs |
.75em | |
fa-sm |
.875em | |
fa-lg |
1.33em | Also applies vertical-align: -25% |
fa-2x |
2em | |
fa-3x |
3em | |
fa-4x |
4em | |
fa-5x |
5em | |
fa-6x |
6em | |
fa-7x |
7em | |
fa-8x |
8em | |
fa-9x |
9em | |
fa-10x |
10em |
Advanced Sizing Customization
If you’re using our SCSS or Less CSS pre-processor options, you
can tweak the _larger.scss
or _larger.less
partial with your own scale.
Fixed Width Icons
Need to vertically align a series of icons, like in a list or navigation menu? We’ve included a fixed-width
support styling for just those cases.
Add a class of fa-fw
on the HTML element referencing your icon to set one or more icons to the same
fixed width. This is great to use when varying icon widths (e.g. a tall but skinny icon atop a wide but short
icon) would throw off vertical alignment. For clarity in the following example, we’ve added a background color
on the icon so you can see the fixed width and also bumped up the font-size of the parent element.
<div style="font-size: 2rem;">
<div><i class="fas fa-skating fa-fw" style="background:DodgerBlue"></i> Skating</div>
<div><i class="fas fa-skiing fa-fw" style="background:SkyBlue"></i> Skiing</div>
<div><i class="fas fa-skiing-nordic fa-fw" style="background:DodgerBlue"></i> Nordic Skiing</div>
<div><i class="fas fa-snowboarding fa-fw" style="background:SkyBlue"></i> Snowboarding</div>
<div><i class="fas fa-snowplow fa-fw" style="background:DodgerBlue"></i> Snowplow</div>
</div>
Icons in a List
Building off of the vertical alignment in our fixed-width styling,
we added some utility styling to handle HTML lists with icons used as decorative bullets.
Use fa-ul
and fa-li
to replace default bullets in unordered lists.
<ul class="fa-ul">
<li><span class="fa-li"><i class="fas fa-check-square"></i></span>List icons can</li>
<li><span class="fa-li"><i class="fas fa-check-square"></i></span>be used to</li>
<li><span class="fa-li"><i class="fas fa-spinner fa-pulse"></i></span>replace bullets</li>
<li><span class="fa-li"><i class="far fa-square"></i></span>in lists</li>
</ul>
<ol class="fa-ul">
<li><span class="fa-li"><i class="fas fa-check-square"></i></span>List icons can</li>
<li><span class="fa-li"><i class="fas fa-check-square"></i></span>be used to</li>
<li><span class="fa-li"><i class="fas fa-spinner fa-pulse"></i></span>replace bullets</li>
<li><span class="fa-li"><i class="far fa-square"></i></span>in lists</li>
</ol>
Rotating Icons
Sometimes you need to rotate, flip, or mirror an icon for it to work in your project or design. We’ve
included some quick utilities to help with that.
To arbitrarily rotate and flip icons, use the fa-rotate-*
and fa-flip-*
classes when
you reference an icon.
<div class="fa-4x">
<i class="fas fa-snowboarding"></i>
<i class="fas fa-snowboarding fa-rotate-90"></i>
<i class="fas fa-snowboarding fa-rotate-180"></i>
<i class="fas fa-snowboarding fa-rotate-270"></i>
<i class="fas fa-snowboarding fa-flip-horizontal"></i>
<i class="fas fa-snowboarding fa-flip-vertical"></i>
<i class="fas fa-snowboarding fa-flip-both"></i>
</div>
Rotate Classes
Class | Rotation Amount |
---|---|
fa-rotate-90 |
90° |
fa-rotate-180 |
180° |
fa-rotate-270 |
270° |
fa-flip-horizontal |
mirrors icon horizontally |
fa-flip-vertical |
mirrors icon vertically |
fa-flip-both |
mirrors icon vertically and horizontally (requires 5.7.0 or greater) |
Combining Rotating + Flipping
Our rotation utilities leverage CSS’s transform property. You can both
rotate and flip an icon, but you’ll need to use some extra markup, such as a <span>
element,
to do so as placing multiple rotate/flip classes on one element will just overwrite one another. Apply one
rotate utility class on the parent element and another on the nested icon.
<div class="fa-4x">
<!-- A icon that's rotated 90 degress and flipped horizontally -->
<span class="fa-rotate-90" style="display: inline-block;">
<i class="fas fa-snowboarding fa-flip-horizontal"></i>
</span>
<!-- A icon that's flipped horizontally and rotated 90 degrees -->
<span class="fa-flip-horizontal" style="display: inline-block;">
<i class="fas fa-snowboarding fa-rotate-90"></i>
</span>
<!-- A icon that's flipped vertically and rotated 270 degress -->
<span class="fa-flip-vertical" style="display: inline-block;">
<i class="fas fa-snowboarding fa-rotate-270"></i>
</span>
<!-- A icon that's rotated 270 degress and flipped vertically -->
<span class="fa-rotate-270" style="display: inline-block;">
<i class="fas fa-snowboarding fa-flip-vertical"></i>
</span>
<!-- A icon that's flipped on both axes and arbitrarily rotated 45 degress -->
<span class="fa-flip-both" style="display: inline-block;">
<i class="fas fa-snowboarding fa-rotate-by" style="--fa-rotate-angle: 45deg;"></i>
</span>
<!-- A icon that's arbitrarily rotated 45 degres and flipped on both axes -->
<span class="fa-rotate-by" style="display: inline-block; --fa-rotate-angle: 45deg;">
<i class="fas fa-snowboarding fa-flip-both"></i>
</span>
</div>
CSS Transforms don’t work with
inline elements!
If you’re using an HTML element that is nativeby default set to display: inline;
, you’ll need to add
a custom rule to change that. In the examples above, we use and generally recommend
display: inline-block
.
Need more control when rotating?
Our SVG + JS framework includes a power transforms feature
that allows for rotating an icon on a more granular scale, even by a single degree! If you’re using Font Awesome
that way, check it out.
Animating Icons
Need a loading or status communicating-icon to spin? You’ve come to the right place. We’ve included some
basic animations in our support styling for you to use.
Use the fa-spin
class to get any icon to rotate, and use fa-pulse
to have it rotate
with eight steps. This works especially well with fa-spinner
& everything in the spinner icons category.
<div class="fa-3x">
<i class="fas fa-spinner fa-spin"></i>
<i class="fas fa-circle-notch fa-spin"></i>
<i class="fas fa-sync fa-spin"></i>
<i class="fas fa-cog fa-spin"></i>
<i class="fas fa-spinner fa-pulse"></i>
<i class="fas fa-stroopwafel fa-spin"></i>
</div>
Icon Animation + Wobbles
We’ve worked hard to keep icons perfectly centered when they are spinning or pulsing. However, we’ve seen
issues with several browsers and the web fonts + CSS version of Font Awesome. Through a lot of
investigation this appears to be an issue with web fonts in general and not something we can directly fix. We do
have a couple of ways you might be able to work around this:
- Switch Frameworks – Switch to the SVG with
JavaScript version, it’s working a lot better for this. - Set the display of the animating icon – Use
display: block;
where you can.
This seems to help a lot with this issue.
Bordered + Pulled Icons
Occasionally you might want to wrap text around an icon or give it some visual distinction with a border.
Here’s how with the support styling we’ve included.
Use fa-border
and fa-pull-right
or fa-pull-left
for easy pull quotes or
article icons.
<i class="fas fa-quote-left fa-2x fa-pull-left"></i>
Gatsby believed in the green light, the orgastic future that year by year recedes before us.
It eluded us then, but that’s no matter — tomorrow we will run faster, stretch our arms further...
And one fine morning — So we beat on, boats against the current, borne back ceaselessly into the past.
Use fa-border
in combination with pulled icon styles for more visual separation.
<i class="fas fa-arrow-right fa-2x fa-pull-right fa-border"></i>
Gatsby believed in the green light, the orgastic future that year by year recedes before us.
It eluded us then, but that’s no matter — tomorrow we will run faster, stretch our arms further...
And one fine morning — So we beat on, boats against the current, borne back ceaselessly into the past.
Stacked Icons
You can stack our icons easily with the support styling bundled with Font Awesome.
To stack multiple icons, use the fa-stack
class on the parent HTML element of the 2 icons you want
to stack. Then add the fa-stack-1x
class for the regularly sized icon and add the
fa-stack-2x
class for the larger icon. fa-inverse
can be added to the icon with the
fa-stack-1x
to help with a knock-out looking effect. You can even throw larger icon classes on the
parent to get further control of sizing.
<span class="fa-stack fa-2x">
<i class="fas fa-square fa-stack-2x"></i>
<i class="fab fa-twitter fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack fa-2x">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fas fa-flag fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack fa-2x">
<i class="fas fa-square fa-stack-2x"></i>
<i class="fas fa-terminal fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack fa-4x">
<i class="fas fa-square fa-stack-2x"></i>
<i class="fas fa-terminal fa-stack-1x fa-inverse"></i>
</span>
<span class="fa-stack fa-2x">
<i class="fas fa-camera fa-stack-1x"></i>
<i class="fas fa-ban fa-stack-2x" style="color:Tomato"></i>
</span>
Aligning Stacked and Regular Icons
You can use stacked icons right alongside single icons. Since stacked icons are styled by our framework’s
included CSS to be twice the size of single icons, you’ll need to either size down the stacked icon or size up
the single icons.
<i class="far fa-circle fa-2x"></i>
<span class="fa-stack" style="vertical-align: top;">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-flag fa-stack-1x"></i>
</span>
<span class="fa-stack" style="vertical-align: top;">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fas fa-flag fa-stack-1x fa-inverse"></i>
</span>
<i class="far fa-circle fa-2x"></i>
Some Custom CSS Required
You’ll need to write your own custom rules if you change the default font-size
of stacked icons as
well as depending on your layout needs (by default stacked icons are set to display: inline-block;
and vertical-align:middle;
).
<style>
.fa-stack { font-size: 0.5em; }
i { vertical-align: middle; }
</style>
<i class="far fa-circle"></i>
<span class="fa-stack">
<i class="far fa-circle fa-stack-2x"></i>
<i class="fas fa-flag fa-stack-1x"></i>
</span>
<span class="fa-stack">
<i class="fas fa-circle fa-stack-2x"></i>
<i class="fas fa-flag fa-stack-1x fa-inverse"></i>
</span>
<i class="far fa-circle"></i>
Need more power while stacking?
Our SVG + JS framework includes powerful ways to mask and layer that allows for rotating an
icon on a more granular scale, even by a single degree! If you’re using Font Awesome that way, check it out.
Heads Up!
This feature requires that you use our SVG + JS version of Font Awesome.
Power Transforms NEW!
Thanks to the power of SVG in Font Awesome 5, now you can scale, position, flip, & rotate icons
arbitrarily using thedata-fa-transform
element attribute. You can even combine them for some
super-useful effects.
Scaling
Power Transform scaling affects icon size without changing or moving the container. To scale icons up or down,
use grow-#
and shrink-#
with any arbitrary value, including decimals. Units are
1/16em. For clarity in the example, we’ve added a background color on the icon so you can see the effect.
<div class="fa-4x">
<i class="fas fa-seedling" data-fa-transform="shrink-8" style="background:MistyRose"></i>
<i class="fas fa-seedling" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="grow-6" style="background:MistyRose"></i>
</div>
Positioning
Power Transform positioning affects icon location without changing or moving the container. To move icons up,
down, left, or right, use up-#
, down-#
, left-#
, and right-#
with any arbitrary value, including decimals. Units are 1/16em. For clarity in the example, we’ve added a
background color on the icon so you can see the effect.
<div class="fa-4x">
<i class="fas fa-seedling" data-fa-transform="shrink-8" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="shrink-8 up-6" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="shrink-8 right-6" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="shrink-8 down-6" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="shrink-8 left-6" style="background:MistyRose"></i>
</div>
Rotating & Flipping
Power Transform rotating & flipping affects icon angle and reflection without changing or moving the
container. To rotate or flip icons use any combination of rotate-#
, flip-v
, and
flip-h
with any arbitrary value. Units are degrees with negative numbers allowed (see fifth icon in
the example). For clarity in the example, we’ve added a background color on the icon so you can see the effect.
<div class="fa-4x">
<i class="fas fa-seedling" data-fa-transform="rotate-90" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="rotate-180" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="rotate-270" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="rotate-30" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="rotate--30" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="flip-v" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="flip-h" style="background:MistyRose"></i>
<i class="fas fa-seedling" data-fa-transform="flip-v flip-h" style="background:MistyRose"></i>
</div>
Did you know?
You can mix and match any of the power transforms noted above together on a single icon.
Heads Up!
This feature requires that you use our SVG + JS version of Font Awesome.
Masking NEW!
Combine two icons create one single-color shape, thanks to the power of SVG in Font Awesome 5! Use it with
our new Power Transforms for some really awesome effects.
Masks are great when you do want your background color to show through. For clarity in the
example, we’ve added a background color on the icon so you can see the effect.
<div class="fa-4x">
<i class="fas fa-pencil-alt" data-fa-transform="shrink-10 up-.5" data-fa-mask="fas fa-comment" style="background:MistyRose"></i>
<i class="fab fa-facebook-f" data-fa-transform="shrink-3.5 down-1.6 right-1.25" data-fa-mask="fas fa-circle" style="background:MistyRose"></i>
<i class="fas fa-headphones" data-fa-transform="shrink-6" data-fa-mask="fas fa-square" style="background:MistyRose"></i>
<i class="fas fa-mask" data-fa-transform="shrink-3 up-1" data-fa-mask="fas fa-circle" style="background:MistyRose"></i>
</div>
To accomplish the masking some SVG definitions are generated. You can control the ID’s used by specifying
data-fa-mask-id
. Available in 5.12.2 or later.
<div class="fa-4x">
<i class="fas fa-pen-alt" data-fa-transform="shrink-10 up-.5" data-fa-mask="fas fa-comment" data-fa-mask-id="comment" style="background:MistyRose"></i>
</div>
Masking components | How it works |
---|---|
Inner Icon (cut out) | Set using typical class attribute. Transform using anydata-fa-transform properties. |
Outer Icon | Set using data-fa-mask attribute on the Inner Icon. |
ID used in defs | Set using data-fa-mask-id (Available in 5.12.2 or later)
|
Heads Up!
This feature requires that you use our SVG + JS version of Font Awesome.
Layering, Text, & Counters
NEW!
Layers are the new way to place icons and text visually on top of each other, replacing our classic icons stacks.
With this new approach, you can use more than two icons. Yuss!
Layers are awesome when you don’t want your page’s background to show through, or when you
do want to use multiple colors, layer several icons, layer text, or layer counters onto an
icon. For clarity in the example, we’ve added a background color on the layers so you can see the effect.
<div class="fa-4x">
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-circle" style="color:Tomato"></i>
<i class="fa-inverse fas fa-times" data-fa-transform="shrink-6"></i>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-bookmark"></i>
<i class="fa-inverse fas fa-heart" data-fa-transform="shrink-10 up-2" style="color:Tomato"></i>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-play" data-fa-transform="rotate--90 grow-2"></i>
<i class="fas fa-sun fa-inverse" data-fa-transform="shrink-10 up-2"></i>
<i class="fas fa-moon fa-inverse" data-fa-transform="shrink-11 down-4.2 left-4"></i>
<i class="fas fa-star fa-inverse" data-fa-transform="shrink-11 down-4.2 right-4"></i>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-calendar"></i>
<span class="fa-layers-text fa-inverse" data-fa-transform="shrink-8 down-3" style="font-weight:900">27</span>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-certificate"></i>
<span class="fa-layers-text fa-inverse" data-fa-transform="shrink-11.5 rotate--30" style="font-weight:900">NEW</span>
</span>
<span class="fa-layers fa-fw" style="background:MistyRose">
<i class="fas fa-envelope"></i>
<span class="fa-layers-counter" style="background:Tomato">1,419</span>
</span>
</div>
Layering components | How it works |
---|---|
fa-layers |
Wraps your stack of icons or text. You’ll likely want to also include anfa-fw class so your layers align. |
Inner icons | Add as many icons as you like directly inside yourfa-layers element. Icons stack with the last icon on the top. |
fa-layers-text |
Add inside your fa-layers element to put text on top of anicon. Combine with data-fa-transform for full control. |
fa-layers-counter |
Adds a counter to the top right of your icons. Can be positioned withfa-layers-bottom-left , fa-layers-bottom-right ,fa-layers-top-left and the default fa-layers-top-right . Overflow textis truncated with an ellipsis. |
Before we start,
review the following and make sure you’re…
- Already set up Font Awesome
in your project. If you haven’t, the quickest way is to make
a kit. - Familiar with the basic
use of Font Awesome icons. - Using Font Awesome Version 5.10.0 or greater
- An active Pro-level plan subscriber or have a Pro license with
access to Version 5.10.0 or greater
Duotone Icons NEW!
Our duotone style works
just like all of our other icons. On top of that, they provide a version of every icon in Font
Awesome that has two distinct shades of color. They’re great for adding more of your brand or an
illustrative quality to the icons in your project.
Basic Use
Duotone icons use the same syntax Font Awesome icons and can be referenced like any other icon using their
specific style prefix (fad
).
<div class="fa-3x">
<i class="fad fa-camera"></i> <!-- a duotone style camera icon -->
<i class="fad fa-fire-alt"></i> <!-- a duotone style fire-alt icon -->
<i class="fad fa-bus-alt"></i> <!-- a duotone style bus-alt icon -->
<i class="fad fa-fill-drip"></i> <!-- a duotone style fill-drip icon -->
</div>
Swapping Layer Opacity
You can swap the default opacity of each duotone icon’s layers. This will make an icon’s primary layer have the
default opacity of 40% rather than its secondary layer.
<div class="fa-3x">
<i class="fad fa-camera"></i> <!-- a duotone style camera icon -->
<i class="fad fa-camera fa-swap-opacity"></i> <!-- a duotone style camera icon with swapped opacity -->
<i class="fad fa-fire-alt"></i> <!-- a duotone style fire-alt icon -->
<i class="fad fa-fire-alt fa-swap-opacity"></i> <!-- a duotone style fire-alt icon with swapped opacity -->
<i class="fad fa-bus-alt"></i> <!-- a duotone style bus-alt icon -->
<i class="fad fa-bus-alt fa-swap-opacity"></i> <!-- a duotone style bus-alt icon with swapped opacity -->
</div>
Your Turn!
Swap until you drop with these Codepen opacity-swapping
examples.
Changing Opacity
By default, the secondary layer in a duotone icon is set to 40% opacity (via an opacity 0.4;
rule in
Font Awesome’s support CSS). You can explicitly set the opacity of a duotone icon’s layer by
using the CSS custom properties below. New to
custom properties? Here are some places to set
them.
Properties | CSS Custom Property | Accepted Values |
---|---|---|
Set Primary Layer Opacity | --fa-primary-opacity |
0 1.0 |
Set Secondary Layer Opacity | --fa-secondary-opacity |
0 1.0 |
<div class="fa-3x">
<i class="fad fa-bus-alt" style="--fa-secondary-opacity: 0.20"></i> <!-- secondary layer's opacity set to 20% -->
<i class="fad fa-bus-alt" style="--fa-secondary-opacity: 0.40"></i> <!-- secondary layer's opacity set to 40% -->
<i class="fad fa-bus-alt" style="--fa-secondary-opacity: 0.60"></i> <!-- secondary layer's opacity set to 60% -->
<i class="fad fa-bus-alt" style="--fa-secondary-opacity: 0.80"></i> <!-- secondary layer's opacity set to 80% -->
<i class="fad fa-bus-alt" style="--fa-secondary-opacity: 1.0"></i> <!-- secondary layer's opacity set to 100% -->
</div>
<div class="fa-3x">
<i class="fad fa-bus-alt" style="--fa-primary-opacity: 0.20"></i> <!-- primary layer's opacity set to 20% -->
<i class="fad fa-bus-alt" style="--fa-primary-opacity: 0.40"></i> <!-- primary layer's opacity set to 40% -->
<i class="fad fa-bus-alt" style="--fa-primary-opacity: 0.60"></i> <!-- primary layer's opacity set to 60% -->
<i class="fad fa-bus-alt" style="--fa-primary-opacity: 0.80"></i> <!-- primary layer's opacity set to 80% -->
<i class="fad fa-bus-alt" style="--fa-primary-opacity: 1.0"></i> <!-- primary layer's opacity set to 100% -->
</div>
Your Turn!
Let’s make sure this concept is super “transparent”. Try tinkering with these different
opacity examples.
Coloring Duotone Icons
Like all other Font Awesome icons, duotone icons automatically
inherit CSS size and color. A duotone icon consists of a primary and
secondary layer. By default, The secondary layer is given an opacity of 40% so that it appears
as a lighter shade of the icon’s inherited or directly set color.
Using CSS custom properties, we’ve also added
some color hooks to a duotone icon’s primary and secondary layers. New to custom properties? Here are some places to set
them.
Properties | CSS Custom Property | Accepted Values |
---|---|---|
Set Primary Layer Color | --fa-primary-color |
Any valid CSS color value |
Set Secondary Layer Color | --fa-secondary-color |
Any valid CSS color value |
<div class="fa-3x">
<i class="fad fa-bus-alt" style="--fa-primary-color: gold;"></i> <!-- primary layer color defined -->
<i class="fad fa-bus-alt" style="--fa-primary-color: orangered;"></i> <!-- primary layer color defined -->
<i class="fad fa-fill-drip" style="--fa-secondary-color: limegreen;"></i> <!-- secondary layer color defined -->
<i class="fad fa-fill-drip" style="--fa-secondary-color: rebeccapurple;"></i> <!-- secondary layer color defined -->
<i class="fad fa-battery-full" style="--fa-primary-color: limegreen; --fa-secondary-color: dimgray;"></i> <!-- secondary + primary layer color defined -->
<i class="fad fa-battery-quarter" style="--fa-primary-color: orange; --fa-secondary-color: dimgray;"></i> <!-- secondary + primary layer color defined -->
</div>
Your Turn!
Here’s a Codepen that has some
coloring examples for you to go cray-cray(ola) with.
Advanced Use
When you combine all of the coloring, opacity, and other options together, Font Awesome icons get even more
awesome. Here are a few ideas on how duotone icons can take your project to the next level…
Use Color to Highlight a Part of an Icon or to Note Status
<div class="fa-3x">
<i class="fad fa-book" style="--fa-primary-color: lightseagreen; --fa-secondary-color: linen; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-book-spells" style="--fa-primary-color: mediumpurple; --fa-secondary-color: linen; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-book-medical" style="--fa-primary-color: crimson; --fa-secondary-color: linen; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-book-user" style="--fa-primary-color: peru; --fa-secondary-color: linen; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-toggle-off" style="--fa-primary-color: white; --fa-secondary-color: gray; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-toggle-on" style="--fa-primary-color: dodgerblue; --fa-secondary-color: white; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-file-plus" style="--fa-primary-color: white; --fa-secondary-color: limegreen; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-file-exclamation" style="--fa-primary-color: white; --fa-secondary-color: gold; --fa-secondary-opacity: 1.0;"></i>
<i class="fad fa-file-times" style="--fa-primary-color: white; --fa-secondary-color: tomato; --fa-secondary-opacity: 1.0;"></i>
</div>
Create Full-Color Icons that Look Like Illustrations
<div class="fa-3x">
<i class="fad fa-crow" style="--fa-secondary-opacity: 1.0; --fa-primary-color: dodgerblue; --fa-secondary-color: gold;"></i>
<i class="fad fa-campfire" style="--fa-secondary-opacity: 1.0; --fa-primary-color: sienna; --fa-secondary-color: red;"></i>
<i class="fad fa-birthday-cake" style="--fa-secondary-opacity: 1.0; --fa-primary-color: pink; --fa-secondary-color: palevioletred;"></i>
<i class="fad fa-ear" style="--fa-secondary-opacity: 1.0; --fa-primary-color: sandybrown; --fa-secondary-color: bisque;"></i>
<i class="fad fa-corn" style="--fa-secondary-opacity: 1.0; --fa-primary-color: mediumseagreen; --fa-secondary-color: gold;"></i>
<i class="fad fa-cookie-bite" style="--fa-secondary-opacity: 1.0; --fa-primary-color: saddlebrown; --fa-secondary-color: burlywood;"></i>
</div>
Theme Icons with Brand Colors
<style>
.theme-ravenclaw {
--fa-secondary-opacity: 1.0;
--fa-primary-color: rgb(4, 56, 161);
--fa-secondary-color: rgb(108, 108, 108);
}
</style>
<div class="fa-3x">
<i class="fad fa-hat-wizard theme-ravenclaw"></i>
<i class="fad fa-flask-potion theme-ravenclaw"></i>
<i class="fad fa-wand-magic theme-ravenclaw"></i>
<i class="fad fa-scarf theme-ravenclaw"></i>
<i class="fad fa-book-spells theme-ravenclaw"></i>
</div>
Your Turn!
Ready for “Advanced Defense Against the Dark Arts” and Duotone Icon Use? Here are some advanced examples you can start
from to cast some real duotone magic. Want to ace those upcoming O.W.L.s on theming? Check out even more examples.
Using in a Project
CSS custom properties are still a pretty new
thing for most folks. Here are some ways you can define them within your project…
Setting Properties with CSS :root
You can define duotone icons’ custom properties at CSS :root pseudo-class level. This will
make any duotone icons you include inherit the properties by default.
<!-- by default, everything will be in the holiday spirit -->
<style>
:root {
--fa-primary-color: green;
--fa-secondary-color: red;
}
</style>
<i class="fad fa-holly-berry"></i>
<i class="fad fa-wreath"></i>
<i class="fad fa-candy-cane"></i>
Setting Properties with Project-Based CSS Rules
You can also set custom properties inside of your project’s CSS, in the <head>
of a page or
in a separate stylesheet. These properties will be scoped to just elements that match the selector of the rule
you’ve included them in. This technique is great for theming in general and when you may not have easy access to
the raw HTML of your project.
<!-- setting a rule for house styling -->
<style>
.theme-slytherin {
--fa-primary-color: darkgreen;
--fa-secondary-color: silver;
}
</style>
<i class="fad fa-wand-magic theme-slytherin"></i>
<i class="fad fa-scarf theme-slytherin"></i>
<i class="fad fa-book-spells theme-slytherin"></i>
Setting Properties with Inline Styles
Many of the examples in these docs define CSS custom properties using inline styling by adding a
style
attribute to an element. This is best for one-offs or very custom colored/styled duotone
icons that you won’t need to change at a system level.
<!-- using inline styles to define duotone icon custom properties -->
<i class="fad fa-crow" style="--fa-primary-color: dodgerblue; --fa-secondary-color: gold;"></i>
Be careful of specificity and cascade!
CSS Custom properties that are redefined will trump each other. Defining a property in :root {}
and
then defining the same property in a rule or inline will result in the :root style being overridden.
Accessibility Best Practices
Because duotone icons are made up of two layers with different color values, they can be more like illustrations
than other Font Awesome styles, and need extra care when it comes to accessibility.
Since they are more complex visually, duotone icons may be harder to read at smaller sizes. In addition to that,
the colors and opacity you choose for each icon’s layers can also affect their legibility. Some tips for
improving legibility and accessibility:
- Render duotone style icons at larger sizes (2x your base type size is a good starting point).
- Test layer colors together to make sure they have enough color contrast.
- Test layer colors together to make sure they handle color-blindness scenarios well.
Duotone Cheatsheet
Properties | Syntax | Values | Notes |
---|---|---|---|
Set Primary Layer Opacity | --fa-primary-opacity |
0 1.0 |
Use as a CSS custom property |
Set Secondary Layer Opacity | --fa-secondary-opacity |
0 1.0 |
Use as a CSS custom property |
Set Primary Layer Color | --fa-primary-color |
Any valid CSS color value |
Use as a CSS custom property |
Set Secondary Layer Color | --fa-secondary-color |
Any valid CSS color value |
Use as a CSS custom property |
Swap Layers’ Opacity | fa-swap-opacity |
N/A | Add alongside other Font Awesome-specific classes to<i> |
Troubleshooting
Can I use Duotone Icons by using CSS pseudo-elements?
Yes, the duotone icon style can be used alongside CSS pseudo-elements.
Doing so is even more
complicated than the base difficulty of rendering icons with CSS pseudo-elements. It’s recommended only
for those who can’t control the final markup of their site/project as well as ninjas who want complete control
over their markup.
Harrumph! The icon I want to use isn’t showing up in duotone style!
Let’s double-check a few things.
- Are you using the duotone-specific
fad
style prefix? - Duotone icons are only available with Font Awesome Pro – make sure you have an active Pro-level plan or a Pro license with access to Version
5.10.0 or greater. - We release icons pretty frequently these days. Make sure you’re using the latest and greatest version so any
new icons you want to use are at your fingertips. - If you’ve decided to host your own copy of Font Awesome, check that you’ve moved all of the files you need
to use the icon you want. Also, double-check the paths to those files in your HTML’s
<head>
.
Help! I can’t target individual layers!
Make sure you’re using the correct custom
property values we’ve defined. Also, make sure you haven’t defined a custom property that may be
overriding things (check inline and in your custom CSS). We don’t recommend writing custom CSS to target a
specific class or pseudo element – there are some differences between our Web Fonts and SVG versions of Font
Awesome that can make this tough.
Can I use other Font Awesome styling alongside duotone icons?
Yep! Things like sizing, fixed-width icons, and animations can all be used
with duotone icons. If you’re using the SVG + JS version of Font Awesome, our power transforms and layering let you do some pretty
amazing stuff.
What browsers will duotone icons work in?
Duotone icons render great in all modern web browsers. Since Internet Explorer (versions 10 and 11) do not
support CSS Custom properties, duotone icons will still render in that browser but you won’t be able to define
colors or opacity for individual layers. If you must support that outdated browser, we recommend defining the
color on the icon or its parent element instead.
Get Started Using Duotone Icons!
Get multi-colored icons on your site lickity-split using one of our hosted kits! Need to host things yourself or work
in a specific language? We’ve got other options too.
Oh, and make sure you peruse our entire
catalog of duotone icons to find the right one for the job.
Uploading Icons THIS IS
CURRENTLY INBETA!
Font Awesome Kits are already the easiest and most performant way to
use Font Awesome on the web. Now you can add your own icons and use them right alongside official Font
Awesome ones! Oh, and icons you upload to a kit include our bulletproof browser support, styling
options, and ease of use you’ve come to expect!
Before we start, make sure
you review the following:
- You have an active Pro-level plan or access to Pro services
- You’ve enabled beta features in your account
settings - The kit you’re uploading to is using Pro icons
- The kit you’re uploading to is using SVG as its technology.
- You’re using Font Awesome Version 5.15.1 or greater
You’ll need to have a Kit using Pro Icons and SVG in order to upload icons
Uploading Icons
Head on over to your kit of choice to get started. From there you can upload SVG files in the “Uploaded Icons”
section of your kit. We accept SVGs via drag and drop, file browsing, and even pasting in the SVG directly — for
those of you who want to copy straight from Adobe Illustrator or edit raw SVG code.
When uploading icons to a kit, we’ll do our best to automagically apply our best practices as we process them.
However, we can’t catch and solve all the ways things could go sideways. So it’s best to familiarize yourself
with how to prep
your icons.
Lastly, here are a few housekeeping notes about uploaded icons:
- Uploaded icons are tied to a specific kit and will only work on projects that reference that kit
- Uploaded icons are only available for web use right now.
- You can upload as many icons as your plan allows (in one or
across many kits). - Uploaded icons can have the same name as official Font Awesome icons (the unique
prefix will set them apart)
Icon Design
Guidelines
If you’re new to making icons or want to become more familiar with our icon grid, shapes, and approach when
designing your own, we’ve put together a starting set of
guidelines to help your icons look and feel right at home next to Font Awesome’s.
Prepping Icons for
Upload
To help your icons display perfectly right alongside official Font Awesome icons, you’ll need to follow
some requirements when creating SVGs. While a bit technical and detail-oriented, it’s nothing you can’t
tackle if you’re already comfortable working in design software like Adobe Illustrator. Check out our
extensive guide for prepping icons to upload (<buzz>
and
beyond!</buzz>
). We’ll walk through all of the things you need to know and do.
Using Uploaded Icons in a Project
Once you’ve uploaded and published your own icons to a kit, they are immediately ready to use in any project
referencing that kit!
Heads Up! Uploaded icons
have their own unique prefix!
To avoid collisions and confusion with official Font Awesome icons, icons uploaded to a kit use the
fak
prefix.
Here’s an example of an HTML file referencing both official and uploaded icons from a kit.
Style | Availability | Prefix | Example |
---|---|---|---|
Solid | Free | fas |
<i class="fas fa-basketball-hoop"></i> |
Regular | Pro Required | far |
<i class="far fa-basketball-hoop"></i> |
Light | Pro Required | fal |
<i class="fal fa-basketball-hoop"></i> |
Duotone | Pro Required | fad |
<i class="fad fa-basketball-hoop"></i> |
Brands | Free | fab |
<i class="fab fa-dribbble"></i> |
Kit Uploads | Pro Services Required |
fak |
<i class="fak fa-fa-basketball-hoop-broken"></i> |
Here’s an example of an HTML file referencing both official and uploaded icons from a kit…
using-uploaded-icons.html
<!doctype html>
<html>
<head>
<!-- Place your kit's code here -->
<script src="[YOUR_KIT_CODE]" crossorigin="anonymous"></script>
</head>
<body>
<!-- official solid icons -->
<i class="fas fa-pennant"></i>
<i class="fas fa-basketball-hoop"></i>
<i class="fas fa-basketball-ball"></i>
<!-- official brand icon -->
<i class="fab fa-dribbble"></i>
<!-- (ficticious) uploaded icons: reference icons you've uploaded to your kit -->
<i class="fak fa-pennant"></i>
<i class="fak fa-basketball-hoop-broken"></i>
<i class="fak fa-shaq-dunking"></i>
<i class="fak fa-shaq-rapping"></i>
</body>
</html>
Uploaded icons can use all of the support styling official Font Awesome icons can, including: sizing, coloring,
rotating, power transforms, masking, and layering. You can also use your uploaded
icons as pseudo-elements.
Running into trouble
uploading or using your own icons?
Check out our guide on
how to troubleshoot common issues.
Performance & Font Awesome
This question comes up a lot: “Which version of Font Awesome should I use to get the best performance?”. Font
Awesome is available in SVG with JavaScript, web fonts with CSS, as SVG sprites, and as raw SVGS. While we
can’t give you a simple answer we can give you an overview of some of the performance characteristics of
each implementation.
Test performance for yourself
Since every site and app are different it’s important that you test and decide which implementation of Font
Awesome works best for you.
SVG with JavaScript
This implementation encodes icon data and the mechanism to display them in the browser in JavaScript code that
the browser executes.
Will be a good choice when:
- you don’t have a very large number of icons to display
- you have a frontend app (like React, Angular, or Vue.js)
- you can use JavaScript subsetting to reduce file size
- the user agent (browser) is less resource-restricted (has a faster CPU and enough memory)
Web Fonts with CSS
This implementation uses web fonts as the file format and relies on the browser to render icons as it would any
custom font.
Will be a good choice when:
- you would prefer the battle-tested and mature web fonts technology
- you have a very large number of icons to display
- the use agent (browser) is resource restricted (slower CPU)
SVG Sprites
This implementation uses a technique where SVG icons are defined in a separate file and then referenced as
symbols in the site.
Will be a good choice when:
- you have a smaller number of icons
- you can’t or don’t want to rely on JavaScript
- you are willing to style with CSS the icons yourself
- the use agent (browser) is resource restricted (slower CPU)
Individual SVG icons
This implementation represents just the raw SVG files where each file is one Font Awesome icon.
Will be a good choice when:
- individual small file (requests) are efficient for you or you are embedding SVG directly in your page
- you can’t or don’t want to rely on JavaScript
- you are willing to style with CSS the icons yourself
Batched Mutations
SVG with JavaScript replaces <i>
tags (and others) matching a set of criteria with
<svg>
.
These operations have been optimized to make use of window.requestAnimationFrame
.
The step of searching / reading the DOM and performing the mutations has been split up. This prevents layout
thrashing in the browser and saves execution time.
https://fontawesome.com/how-to-use/on-the-web/referencing-icons/icon-cheatsheet
Icon Cheatsheet
Now that you’ve gotten everything set up and know how to reference icons, our online documentation makes it easier for you to find and insert icons with a few helpers.
Built into Our Icon Search
In our icon gallery and search listings, we’ve provided a quick way to toggle some extra information on or off for each icon listed. That extra information includes each icon’s name, Unicode character value, and a control to copy the icon as a glyph.
Toggle that ‘Show Cheatsheet’ button on Font Awesome’s icon listing views
Once toggled on, you’ll see extra information about each icon.
The Cheatsheet Itself
Since version 4, we also have a dedicated cheat sheet view that contains all of the information in our icon gallery/search views for all of our icons. This cheat sheet can be saved as a PDF through your print settings for easy search + find when you’re offline or when you want to share icon listings with a team.
The cheat sheet contains rows of information for all icons. And there’s a free and pro version to use and share
Each icon has its name, rendering (which doubles as a copyable glyph), and Unicode value
So, when and how do I use this icon info?
These helpers can be used for both of web and desktop workflows. Here’s a summary of what each piece of info is good for.
Icon Information | What it’s good for |
---|---|
Name | Referencing the icon in HTML (e.g. <i class="fas fa-[NAME]"></i> ) or for when using ligatures on the desktop |
Unicode | For using CSS pseudo elements to render icons |
Glyph | For copying and pasting into a text layer on the desktop or as an alternative way to reference an icon on the web (e.g. <i class="fas">[GLYPH]</i> ) into |
Using Web Fonts with CSS
The /css/all.css
file contains the core styling plus all of the icon styles that you’ll need when using Font Awesome. The /webfonts
folder contains all of the typeface files that the above CSS references and depends on.
Copy the entire /webfonts
folder and the /css/all.css
into your project’s static assets directory (or where ever you prefer to keep front end assets or vendor stuff).
Add a reference to the copied /css/all.css
file into the <head>
of each template or page that you want to use Font Awesome on.
page.html
<head>
<link href="/your-path-to-fontawesome/css/all.css" rel="stylesheet"> <!--load all styles -->
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="far fa-user"></i> <!-- uses regular style -->
<i class="fal fa-user"></i> <!-- uses light style -->
<!--brand icon-->
<i class="fab fa-github-square"></i> <!-- uses brands style -->
</body>
Using a CSS Pre-Processor?
Using the /scss
or /less
versions of Font Awesome we’ve bundled in the download? Check out our Sass and Less docs for details on their contents. Once you’ve compiled them into CSS, you can follow the CSS-focused steps noted here to handle hosting and referencing icons.
Using SVG with JavaScript
The /js/all.js
loads all of the base features, plus all of the icon styles that you’ll need when using Font Awesome. Copy it into your project’s static assets directory (or where ever you prefer to keep front end assets or vendor stuff).
Add a reference to the copied /js/all.js
file within the <head>
of each template or page that you want to use Font Awesome on.
template.html
<head>
<script defer src="/your-path-to-fontawesome/js/all.js"></script> <!--load all styles -->
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="far fa-user"></i> <!-- uses regular style -->
<i class="fal fa-user"></i> <!-- uses light style -->
<!--brand icon-->
<i class="fab fa-github-square"></i> <!-- uses brands style -->
</body>
Double-Check Your Paths
Since you’re managing all of the downloaded files yourself, make sure the references in your pages’ <head>
are accurate with where you’ve moved all of Font Awesome’s files in your project.
Using Just Certain Styles
Want to use just certain styles of icons when using our Web Fonts with CSS framework? The /css
folder contains the core styling and additional files for all of Font Awesome’s style options – solid, regular, light, and brands. The /webfonts
folder contains all of the typeface files that the above CSS references and depends on.
Icon Style | Web Font Filename | CSS Filename | Availability |
---|---|---|---|
Font Awesome Brands | fa-brands-400.* |
brands.css |
Free |
Font Awesome Solid | fa-solid-900.* |
solid.css |
Free |
Font Awesome Regular | fa-regular-400.* |
regular.css |
Pro only |
Font Awesome Light | fa-light-300.* |
light.css |
Pro only |
Copy both the /webfonts
and the /css
folders into your project’s static assets directory (or where ever you prefer to keep front end assets or vendor stuff). You can remove any styles’ .css
and web font files you don’t plan on using if you’d like.
Add a reference to the core styling file (/css/fontawesome.css
) and the CSS for individual styles (e.g. /css/brands.css
) into the <head>
of each template or page that you want to use Font Awesome on. Pay attention to the pathing of your project and where you moved the files to in the previous step.
using-certain-styles.html
<head>
<!-- Our project just needs Font Awesome Solid + Brands -->
<link href="/your-path-to-fontawesome/css/fontawesome.css" rel="stylesheet">
<link href="/your-path-to-fontawesome/css/brands.css" rel="stylesheet">
<link href="/your-path-to-fontawesome/css/solid.css" rel="stylesheet">
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="fab fa-github-square"></i> <!-- uses brand style -->
</body>
Mind the Paths in Web Fonts
We recommend keeping the /webfonts
and /css
folders in the same directory. If you don’t, you’ll need to change the path to the web fonts mentioned in each style’s CSS file.
Want use only certain styles when using our SVG with JS framework? The /js
folder contains the core styling and additional files for all of Font Awesome’s style options – solid, regular, light, and brands.
Icon Style | JS Filename | Availability |
---|---|---|
Font Awesome Brands | brands.js |
Free |
Font Awesome Solid | solid.js |
Free |
Font Awesome Regular | regular.js |
Pro only |
Font Awesome Light | light.js |
Pro only |
Copy the fontawesome.js
loader and whatever icon styles’ .js
files you’d like to use into your project’s static assets directory (or where ever you prefer to keep front end assets or vendor stuff). We recommend referencing the fontawesome.js
loader last.
using-certain-styles.html
<head>
<!-- Our project just needs Font Awesome Solid + Brands -->
<script defer src="/your-path-to-fontawesome/js/brands.js"></script>
<script defer src="/your-path-to-fontawesome/js/solid.js"></script>
<script defer src="/your-path-to-fontawesome/js/fontawesome.js"></script>
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="fab fa-github-square"></i> <!-- uses brand style -->
</body>
Double-Check Your Paths
Since you’re managing all of the downloaded files yourself, make sure the references in your pages’ <head>
are accurate with where you’ve moved all of Font Awesome’s files in your project.
Next Steps
With the references complete, you can now start referencing icons in your templates or pages’ <body>
and then check out all of the styling support we pack into those supporting files you’ve loaded.
Using a Package Manager
Package managers like npm and yarn are probably familiar tools for you and your team. With them, you can easily upgrade to newer versions of Font Awesome when they are released and better manage access to Pro packages.
What’s in the Font Awesome Package?
The Web-focused Font Awesome Package contains the following directories and files:
Path | What It Is | Where You Should Start |
---|---|---|
/css |
Stylesheets for Web Fonts | all.css |
/js |
SVG with JavaScript | all.js |
/less |
Less pre-processor | fontawesome.less |
/scss |
Sass pre-processor | fontawesome.scss |
/sprites |
SVG sprites | solid.svg |
/svgs |
Individual SVG for each icon | individual *.svg icons |
/webfonts |
Web Font files used with CSS | See /css |
Installing the Free version of Font Awesome
You can easily install the latest free version of Font Awesome via npm or yarn:
npm install --save @fortawesome/fontawesome-free
See this Stack Overflow question on the difference between --save
and --save-dev
.
yarn add @fortawesome/fontawesome-free
Yarn also lets you use --dev
to save as a development dependency.
Installing the Pro version of Font Awesome
Access to the Pro packages, which contain more icons and styles, requires you to configure the @fortawesome
scope to use our Pro NPM registry.
Keep it secret! Keep it safe!
Your token sfsdfsdf
is used to give you access to Pro packages. So keep it secret and only share it with people who should have access to it.
You have a couple of options on how to configure the @fortawesome
scope to use our Pro NPM registry:
Global Set Up – Globally set these values, so it works in any project:
npm config set "@fortawesome:registry" https://npm.fontawesome.com/
npm config set "//npm.fontawesome.com/:_authToken" XXXXXXXXXXXXXX
Per-Project – If you’d prefer a per-project setting (great for teams and CI/CD), create a .npmrc
file in the root of your project (or where you have your package.json
file):
.npmrc
@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=AE604328-372B-4686-A557-3DED449DF860
After that configuration, you can install the latest Pro version of Font Awesome via npm or yarn:
npm install --save @fortawesome/fontawesome-pro
See this Stack Overflow question on the difference between --save
and --save-dev
.
yarn add @fortawesome/fontawesome-pro
Yarn also lets you use --dev
to save as a development dependency.
Environment variables – You can also leverage NPM’s environment variables replacing:
.npmrc
@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=${FONTAWESOME_NPM_AUTH_TOKEN}
FONTAWESOME_NPM_AUTH_TOKEN=AE604328-372B-4686-A557-3DED449DF860 npm install --save @fortawesome/fontawesome-pro
We have phased out the old method of npm registry authentication
The old way set just one configuration key, which combined the server address and your token. This new way sets two different configuration keys: one for the server address and a second for your token. If you’re currently doing it the old way, please update your configuration to this new way. Make sure that you remove any yarn.lock or package-lock.json file prior to installing again as these files will have the old unsupported URLs in them.
Next Steps
Reference either the /css/all.css
or the /js/all.js
, which contains everything you need to use Font Awesome in the <head>
of each template or page that you want to use Font Awesome on. Be mindful of paths from where you installed the package from when doing so.
Want just certain styles of icons? – If you would like only to use specific styles rather than the default all
option we’ve included in our Web Fonts and SVG frameworks, reference the specific styles you want to use like fa-brands
or fa-regular
and then the loader fontawesome
in place of all
.
using-certain-styles.html
<head>
<!-- Our project just needs Font Awesome solid + brand -->
<script defer src="/your-path-to-fontawesome/js/brands.js"></script>
<script defer src="/your-path-to-fontawesome/js/solid.js"></script>
<script defer src="/your-path-to-fontawesome/js/fontawesome.js"></script>
</head>
<body>
<i class="fas fa-user"></i> <!-- uses solid style -->
<i class="fab fa-github-square"></i> <!-- uses brand style -->
</body>
After you get things installed, check out all of our icons and learn how to reference them in HTML.
Using the npm Download
As a backer of Font Awesome 5, you have access to download the Pro npm packages and use them in your projects. These packages could be installed from a filesystem, accessed through a private URL, or hosted on your own private npm registry. They can then be used like any other npm dependency.
Pro packages are commercial software!
Making the files in these packages publicly available violates your Pro license. So you will need to keep them private.
Using the Local Filesystem
-
Download the npm package(s) from the ‘Pro Packages’ section of our download page. For example, we will download the npm package for the Duotone style.
-
Save the package to your computer (ex:
/Users/fontawesome/development
). -
Install the package into your project:
npm install /Users/fontawesome/development/fortawesome-pro-duotone-svg-icons-5.13.1.tgz
Using a Private URL
-
Download the npm package(s) from the ‘Pro Packages’ section of our download page.
-
Save the package to an internal, private server that can be accessed via a URL.
-
Install the package into your project:
npm install https://internal.yourcompany.com/npm/fortawesome-pro-duotone-svg-icons-5.13.1.tgz
All other Font Awesome npm packages, like @fortawesome/fontawesome-svg-core
, can be installed using the public npm registry. You can find more information on how to use the packages with our getting started guide. More information for installing npm packages can be found at https://docs.npmjs.com/cli/install.
Using a Package ManagerBasic Use
https://fontawesome.com/how-to-use/on-the-web/advanced/css-pseudo-elements
Heads up! We changed the unicode values of some of the icons!
In version 5.12.0 we began to use unicode codepoints that fell outside of the defined Private Use Area (PUA). We’ve corrected this in Version 5.14.0.
If you are using icons that were released in 5.12 or 5.13, you’ll want to update your unicode values.
CSS Pseudo-elements
This is not for the Faint of Heart nor Front End Development
Manually referencing icons this way is more complicated and prone to errors than the standard way of dropping an extra i
element into your markup. So take a pause and consider if this is really worth it. We find this the best option for folks who can’t control the final markup of their site/project as well as those ninjas who want complete control over their markup.
When changing the HTML on your project is not an option, we can leverage a feature of CSS to add icons to a page. CSS has a powerful feature known as Pseudo-elements. Font Awesome has leveraged the
::before
pseudo-element to add icons to a page since the very beginning.
How They Work
We’ve already learned that Font Awesome uses classes like fa
and fa-user
to show icons in your site. Let’s duplicate the functionality of these classes and write our own.
<style>
.icon::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
.login::before {
font-family: "Font Awesome 5 Free"; font-weight: 900; content: "\f007";
}
.tps::before {
font-family: "Font Awesome 5 Free"; font-weight: 400; content: "\f1ea";
}
.twitter::before {
font-family: "Font Awesome 5 Brands"; content: "\f099";
}
</style>
<ul style="margin: 0;">
<li><span class="icon login"></span> Login</li>
<li><span class="icon tps"></span> TPS Reports</li>
<li><span class="icon twitter"></span> Twitter</li>
</ul>
How to Define an Icon Using CSS Pseudo-Elements
Define Common CSS for All Icons
Firstly, there are some common CSS properties that apply to all icons. It’s best to get this out of the way first in your CSS so that your icon definitions become simple.
Reference Individual Icons
There are four important parts to include when referencing any individual icon:
- Set the pseudo-element to match either the
::before
or::after
you used in the previous common set up step. - Set the
font-family
to the right family for the icons you want to use (see family table below). - Set the
font-weight
to the right weight for the style you want to use (see style table). - Set the content to the Unicode value of one of our icons. You may find our cheatsheet handy for finding and copying those values.
Style | Availability | @font-face weight | @font-face font-family |
---|---|---|---|
Solid | Free Plan | 900 |
Font Awesome 5 Free or Font Awesome 5 Pro (for pro users) |
Regular | Pro Plan Required | 400 |
Font Awesome 5 Pro |
Light | Pro Plan Required | 300 |
Font Awesome 5 Pro |
Duotone | Pro Plan Required | 900 |
Font Awesome 5 Duotone |
Brands | Free Plan | 400 |
Font Awesome 5 Brands |
Uploaded Icons | Pro Plan Required | 400 |
Font Awesome Kit |
your.css
/* Step 1: Common Properties: All required to make icons render reliably */
.icon::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
/* Step 2: Reference Individual Icons */
.login::before {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f007";
}
/* Note: Make sure to include the correct weight and Unicode value for the icon */
.tps::before {
font-family: "Font Awesome 5 Free";
font-weight: 400;
content: "\f1ea";
}
Your Turn!
Need a more hands-on example of how to do this? Here’s a Codepen demo showing how to render icons of all styles via CSS Pseudo-elements with our Web Fonts-based Framework.
Using CSS Pseudo-elements with Duotone Icons
Using CSS pseudo-elements to render duotone icons follows a similar setup, but requires the use of both the ::before
and ::after
pseudo-elements along with more styling setup.
Define Common CSS for Duotone Icons
There are shared CSS properties, which are unique to the duotone style, that all duotone icons will need. Again, it’s best to get this out of the way first in your CSS so that your icon definitions become simple.
- Add styling to element that will contain the pseudo-element to support positioning.
- Set the
font-family
toFont Awesome 5 Duotone
, thefont-weight
to900
, and add positioning styles for the pseudo-element. - Set the default opacity levels and colors for each layer of the duotone icon.
Reference Individual Icon’s Layers
Referencing individual duotone icons works much like all CSS pseudo-element icon use. Set the content to the Unicode value of one of our icons. You may find our cheatsheet handy for finding and copying those values.
your.css
/* Step 1: Common Duotone Properties: All required to make icons render reliably */
.icon-duotone {
position: relative;
padding-left: 1.25em; /* make space for the width of the absolutely positioned icon */
}
/* Step 2: Set the font-family and font-weight for this style */
.icon-duotone::before,
.icon-duotone::after {
font-family: "Font Awesome 5 Duotone";
font-weight: 900;
/* position both layers of the icon to the left, set our fixed-width width, horizontally center layers, and then vertically align them so they flex with different line heights */
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 1.25em;
text-align: center;
}
/* Step 3: Set the default opacity levels and colors for each layer */
.icon-duotone::before {
color: var(--fa-primary-color, inherit);
opacity: 1;
opacity: var(--fa-primary-opacity, 1.0);
}
.icon-duotone::after {
color: var(--fa-secondary-color, inherit);
opacity: var(--fa-secondary-opacity, 0.4);
}
/* Step 4: Reference Individual Icon's Layers */
.icon-login::before {
content: "\f007";
}
.icon-login::after {
content: "\10f007";
}
Using CSS Pseudo-elements with Our SVG + JS Framework
If you’re using our SVG + JS framework to render icons, you need to do a few extra things:
Enable Pseudo-elements
Using CSS Pseudo-elements to render icons is disabled by default when using our SVG + JS Framework. You’ll need to add the<script data-search-pseudo-elements ... >
attribute to the <script />
element that calls Font Awesome.
Set Pseudo-elements’ display to none
Since our JS will find each icon reference (using your pseudo-element styling) and insert an icon into your page’s DOM automatically, we’ll need to hide the real CSS-created pseudo-element that’s rendered.
pseudo-and-svg+js.html
<html>
<head>
<script data-search-pseudo-elements defer src="https://use.fontawesome.com/releases/latest/js/all.js" integrity="sha384-L469/ELG4Bg9sDQbl0hvjMq8pOcqFgkSpwhwnslzvVVGpDjYJ6wJJyYjvG3u8XW7" crossorigin="anonymous"></script>
<style>
.icon::before {
display: none;
}
.login::before {
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f007";
}
.tps::before {
font-family: "Font Awesome 5 Free";
font-weight: 400;
content: "\f1ea";
}
</style>
</head>
<body>
<ul style="margin: 0;">
<li><span class="icon login"></span> Login</li>
<li><span class="icon tps"></span> TPS Reports</li>
</ul>
</body>
</html>
See it in Action!
We know this can be tough to get. Here’s a Codepen demo showing how to render icons via CSS Pseudo-elements with our SVG + JS Framework.
Using CSS Pseudo-elements with Uploaded Icons
You can add your uploaded icons to your designs using pseudo-elements, but you’ll need to take a couple of different steps.
Get the Unicode Value
Go to the Uploaded Icons page of your kit, open up the details of the icon you want to use, and copy the unicode value.
Reference the Unicode and Kit Font Family
Set the font to font-family: "Font Awesome Kit"
and use that unicode in your CSS along with the regular settings for using Font Awesome pseudo-elements, like this:
your.css
/* Step 1: Common Properties: All required to make icons render reliably */
.icon::before {
display: inline-block;
font-style: normal;
font-variant: normal;
text-rendering: auto;
-webkit-font-smoothing: antialiased;
}
/* Step 2: Reference Individual Icons */
.custom-icon::before {
font-family: "Font Awesome Kit";
content: "\e001"; /* change to your icon's unicode value */
/* font-weight isn't needed */
}
Support for Dynamic Changes
Let’s get a little cute with it by using some JavaScript and jQuery to toggle the class of an element.
<script>
setInterval(function () {
$('.ninety-four').toggleClass('arrow')
}, 1000)
</script>
<style>
.ninety-four::after {
margin-left: 0.25em;
font-size: 2em;
vertical-align: middle;
font-family: "Font Awesome 5 Free";
font-weight: 900;
content: "\f0c8";
}
.ninety-four.arrow::after {
content: "\f152";
}
</style>
<a class="ninety-four" href="https://en.wikipedia.org/wiki/Blink_element">Hey, do you remember the blink tag?</a>
Upgrading a Project Using Pseudo-elements and Version 4
If you’ve used Pseudo-elements and Version 4 in a project and are looking to upgrade, we strongly recommend using a kit to host and serve Font Awesome 5.
We’ve added a Version 4 Compatibility feature for use right out of the box, err, kit. This feature will help map your Version 4 Unicode references to the proper Version 5 ones. If you have CSS that hard codes Version 4’s font-family name, this auto-update will make sure all of those cases use the current version of Font Awesome from your kit.
SVG Sprites
Want the wonderful goodness of SVG without having the need for our SVG + JS framework at the moment? Have no fear, SVG Sprites are here. We have lovingly prepped all the icon set styles into their own SVG sprites.
Basic Use
- Grab one of the sprite files.
- Place this file with the rest of your static files, like CSS or images, in your project.
- In the
body
of your document call the individual icon you want to use.
<header>
<ul>
<li>
<a href="https://facebook.com/fontawesome">
<svg>
<use xlink:href="fa-brands.svg#facebook"></use>
</svg>
</a>
</li>
<li>
<a href="https://twitter.com/fontawesome">
<svg>
<use xlink:href="fa-brands.svg#twitter"></use>
</svg>
</a>
</li>
<li>
<a href="https://github.com/FortAwesome/Font-Awesome">
<svg>
<use xlink:href="fa-brands.svg#github"></use>
</svg>
</a>
</li>
</ul>
</header>
Issues with SVG sprites
SVG sprites have a few tricky points you need to know about.
Internet Explorer doesn’t load remote SVGs
If you use a URL in the xlink:href
IE will not automatically download the file for you. Check out this project if this is something you need.
Same origin policy
If you use URLs in the xlink:href
they need to be loaded from the same domain. There is cross-origin protection on SVGs loaded this way. Some people just serve it directly from their static assets. You can also use a proxy.
Heads Up!
This feature requires that you use our SVG + JS version of Font Awesome.
SVG Symbols
You can leverage the SVG Sprites technique to make repeated icons more performant on your page.
You might be wondering how rendering icons with JavaScript affects performance. We worried about this quite a bit while we were developing it and even took some special measures to make sure it was as fast as we could make it.
Our testing shows that for the typical number of icons most people use on a site the loading and rendering time is faster than web fonts. Your mileage may vary, of course, and we’d love to hear about your experience if this turns out not to be the case for you.
Example
See this working on CodePen.io.
3 icons repeating
We’ll define these icons as symbols: pencil, trash, and star.
<!-- Define the symbols, these are invisible on the page -->
<i data-fa-symbol="delete" class="fas fa-trash fa-fw"></i>
<i data-fa-symbol="edit" class="fas fa-pencil fa-fw"></i>
<i data-fa-symbol="favorite" class="fas fa-star fa-fw"></i>
<!-- Use the defined symbols -->
<svg><use xlink:href="#edit"></use></svg>
<svg><use xlink:href="#delete"></use></svg>
<svg><use xlink:href="#favorite"></use></svg>
Using data-fa-symbol
informs Font Awesome SVG with JavaScript to create the symbol. The value of this attribute becomes the name.
<!-- Name symbols with the value of data-fa-symbol -->
<i data-fa-symbol="picture-taker" class="fas fa-camera"></i>
<!-- Use the defined name -->
<svg><use xlink:href="#picture-taker"></use></svg>
Watch your CSS, Goose
One of the downsides to SVG sprites is that extra styling is necessary to make them behave. When using symbols you will need to handle this yourself.
<!-- A quick, reasonable place to start with styling your symbols -->
<style>
.icon {
width: 1em;
height: 1em;
vertical-align: -.125em;
}
</style>
<!-- Name symbols with the value of data-fa-symbol -->
<i data-fa-symbol="picture-taker" class="fas fa-camera"></i>
<!-- Use the defined name -->
<svg class="icon"><use xlink:href="#picture-taker"></use></svg> Who doesn't like wafels?
SVG JavaScript Core
We provide more advanced packages that are suitable for more specialized situations. These packages are side-effect free and provide no automatic replacement of
<i>
tags to<svg>
tags. (Although it can still be used throughdom.watch()
).
Check out the API for detailed docs
The @fortawesome/fontawesome-svg-core
package documentation can be found in our API docs
When should you reach for this bad boy?
The SVG core package is helpful and recommended in the following cases:
- to subset a large number of icons into only the icons that you are using
- as base libraries for larger integrations with tools like React, Angular, Vue, or Ember (in fact our own components use these packages)
- as CommonJS/ES6 Modules bundling tool like Webpack, Rollup, or Parcel
- as UMD-style loader library like RequireJS
- directly on the server with CommonJS (see our Server Side Rendering docs)
These are ES6 module compatible for tools that support this, such as Rollup. Our icon content packages also support tree shaking which allows compatible tools to remove icons you are not using from your final build.
Comparing Font Awesome (JavaScript) and Font Awesome (JavaScript) SVG Core
Our Basic packages (@fortawesome/fontawesome-free
and @fortawesome/fontawesome-pro
) are aimed at individuals who would like to quickly integrate Font Awesome into their projects but do not want to invest the time and effort to understand what’s going on under the hood. For this reason a lot of the behavior is automatic and works without any intervention.
In contrast, the fontawesome-svg-core
package is for more specialized situations or for forming the underlying API to power other components or libraries. In fact, our own official components for Vue, React, Ember, and Angular all use the fontawesome-svg-core
package under the hood.
Because of this the core package and the icon content packages avoid doing anything automatic or creating side-effects that make development with them difficult to control or reason.
One of the most common use cases where you would reach for the core package instead of using fontawesome-free
or fontawesome-pro
is to create a subset of icons to reduce your final bundled file size.
For this case you may still want the <i>
tags to be replaced with <svg>
tags. This is the default behavior when using the CDN or fontawesome-free
and fontawesome-pro
packages. This does not happen automatically when using the core package.
To accomplish this we will use the dom
API.
import { library, dom } from '@fortawesome/fontawesome-svg-core'
import { faUserAstronaut } from '@fortawesome/free-solid-svg-icons'
// We are only using the user-astronaut icon
library.add(faUserAstronaut)
// Replace any existing <i> tags with <svg> and set up a MutationObserver to
// continue doing this as the DOM changes.
dom.watch()
More about the API
More information can be found about the Font Awesome API which includes configuration and methods that can be used to tailor your usage as you see fit.
SVG Asynchronous Loading
Using JavaScript to load SVG icons provides a non-blocking mechanism to show icons on a page. If you want more fine-grained control over how icons appear you can use CSS and our loading events.
While async icon loading allows the page to render sooner it can also make page layouts shift.
You can avoid icons loading and shifting your layout or text by leveraging some classes that are added to the <html>
tag as part of the loading operations that the JavaScript engine performs.
<html>
<head></head>
<body>
<i class="fas fa-user"></i> My User
<script defer src="/static/fontawesome/fontawesome-all.js"></script>
</body>
</html>
As the browser begins to search for icons the <html>
tag will contain fontawesome-i2svg-pending
. (i2svg
is our abbreviation for converting “i tags to SVG”)
<html class="fontawesome-i2svg-pending">
...
After icon replacement has completed the pending class will be replaced with fontawesome-i2svg-complete
and the fontawesome-i2svg-active
will be added as well.
<html class="fontawesome-i2svg-active fontawesome-i2svg-complete">
...
The fontawesome-i2svg-active
class will remain once the first successful loading of icons has finished. However, if another batch of icons is loaded the complete
will switch to pending
again.
<html class="fontawesome-i2svg-active fontawesome-i2svg-pending">
...
And again once the icon replacement occurs we get back to our complete
event.
<html class="fontawesome-i2svg-active fontawesome-i2svg-complete">
...
This allows us to do some interesting things with CSS. For example we could hide the <body>
until the icons were loaded.
body {
display: none;
}
.fontawesome-i2svg-active body {
display: initial;
}
Of if we want to only show certain sections once icons are replaced.
<main>
<div>Main section that always shows</div>
<div class="wait-for-icons">
<i class="fas fa-camera"></i> I like cameras
</div>
</main>
.wait-for-icons {
display: none;
}
.fontawesome-i2svg-active .wait-for-icons {
display: initial;
}
Conflict Detection NEW!
When you have multiple versions of Font Awesome loading and creating conflicts, the results can be unpredictable and frustrating to resolve. Use this conflict detector to discover those problems automatically. It won’t fix the problems for you (yet!), but knowing is half the battle.
Font Awesome is used in lots of themes and plugins for various web frameworks like WordPress or Jekyll. They could be including their own versions of Font Awesome, conflicting with each other or with the Font Awesome 5 you’re trying to add to your site. Or maybe you already added Font Awesome 4.7 to your web site years ago, and forgot to remove when upgrading to Font Awesome 5. It happens.
For Diagnostic Use Only!
This tool is not intended to run all the time on your web site. You should enable it only long enough to help you identify troublesome conflicts, and then remove the conflict detector. It won’t change the look of your web pages, but it will do a bunch of extra work behind the scenes that may affect performance and is unnecessary for normal page views.
Enable Conflict Detection
With a Kit Go to your kit’s settings page, enable the Conflict Detection feature, and save your kit. This will temporarily enable conflict detection for that kit.
Without a Kit Grab this embed code and put it in your page template, preferably right before the closing </body>
tag.
<script
type="text/javascript"
src="https://use.fontawesome.com/releases/v5.15.1/js/conflict-detection.js">
</script>
You can change the v5.15.1
in the src
url to any version number, as long as it’s version 5.10.0 or later.
View the Results
Use a desktop web browser to load a page on your web site on which you’d like to detect Font Awesome conflicts. Then open the console.
On a Mac
Browser | Finding the Console | Keyboard Incantation |
---|---|---|
Google Chrome | View Developer JavaScript Console | Option Command J |
Firefox | Tools Web Developer Web Console | Option Command K |
Safari | Develop Show JavaScript Console | Option Command C * |
* You may need to first check “Show Develop menu in menu bar” in Safari’s Advanced settings
On Windows
Browser | Finding the Console | Keyboard Incantation |
---|---|---|
Google Chrome | Menu More tools Developer tools. Then select the “Console” tab. | Ctrl Shift I |
Firefox | Menu Web Developer Web Console | Ctrl Shift K |
Edge | Menu More tools Developer Tools | F12 |
There may already be output from the conflict detector in that web console you just opened. Either way, it’s probably good to just go ahead and reload the page, keeping your eye on that console. After it does its magic, you’ll see a report that might look like this:
That screenshot is taken from Chrome on a Mac, but it should look pretty similar in any modern browser console.
In this example, the conflict detector found four different <link>
, <style>
, or <script>
tags that might be loading conflicting versions of Font Awesome, and it tested each of them.
That <style>
under the green “No conflict” heading isn’t causing us any problems. It’s just setting a background-color
. You can see a little of it in that “innerText excerpt” column.
Our problems are under the red “Conflicts found” heading. The detector found:
- A
<script>
trying to load a version of Font Awesome 5.0.0 fromuse.fontawesome.com
. You can see the URL it’s loading from in that “src/href” column. - A
<link>
is trying to load a version of Font Awesome 4.7 fromcdn.jsdelivr.net
. - A
<style>
is defining another version of Font Awesome 4.7 by including the CSS code inline in the page. Again you can also see a little excerpt of the CSS code contained in that<style>
.
If you left all of those in your page, you’d no doubt experience all kinds of unpredictable results. You might see icons, but maybe not for the correct version of Font Awesome. In some cases, you might see missing icon indicators or empty boxes.
Resolve your Conflicts
In Static HTML Files
If you’re using static HTML files for your web site, then you can probably just search for these conflicts in your HTML files and delete the offending tags. Easy enough.
This is where the src/href or innerText excerpt in the report comes in handy. You can use it to help you track down each conflicting element in your web page.
Just open the HTML source code of your web page and search for part of URL from the src/href, or some part of the innertText excerpt. That will help you locate the conflicting element. Once you find it, you’ll have to decide, based on how your web site works, whether it’s safe to cut out that conflicting element.
Usually, it is safe to remove these conflicting elements, especially if it’s one of those <link>
or <script>
tags that just has a src
or href
attribute or URL pointing to a standard Font Awesome distribution, like you see in this example. Most of the time, if you’re installing your own newer version of Font Awesome 5, then that version will provide all of the icons and classes that your web site needs, including those that other themes or plugins need. So removing these extra tags removes the conflicts, while your newer version of Font Awesome 5 continues providing the icons those other themes or plugins are expecting to be there.
(You might also need to add v4 compatibility, though, since those other themes or plugins might be expecting v4 icons. We have magic for that too.)
If your conflict is a link to a theme stylesheet, for example, then you probably should not just yank it out. Sometimes theme developers will include Font Awesome within their own theme CSS files. In that case, removing the conflicting element would also remove that theme CSS, which is surely not what you want. This is a tricky problem that will be more difficult to resolve, and very specific to the way your theme works. You may need to report the situation to your theme developer and see if they have a workaround for you. We also have some other tools in the works that may help here, when they become available.
In Web Frameworks: WordPress, Jekyll, Rails, Laravel, Phoenix, Eleventy, Django, …
If your web site uses a web framework that generates HTML output from page templates, then there’s no one way to resolve these conflicts, because each framework has its own way of incorporating <script>
, <link>
, or <style>
tags into those templates.
But the basic idea is the same as when removing conflicting elements from static HTML files: figure out how to remove the conflicting tags from the page templates.
If you’re using our WordPress plugin, then you’re in luck. You can just enable the Remove unregistered clients feature and it will automatically remove some or all of these conflicts for you!
We have some other conflict resolution tools in the works that will improve the results in WordPress and that will be useful in all other web environments as well. Stay tuned.
Advanced: Use JavaScript
Hey developers, you see those hashes in the “index” column of the report? Those are md5 checksums computed on each element, based on the src
or href
, if present, or the innerText
otherwise. You could write a script to search for DOM nodes with those checksums and remove them from the DOM on the fly.
One advantage of this approach is that it allows you to snip away those conflicting elements in the browser if, for some reason, you can’t modify the page templates. It’s probably best to remove them from the page templates and not run extra code in the browser, if possible. But that’s your call.
To help you with development, the conflict detector, once loaded, puts an md5ForNode
function on a global window.FontAwesomeDetection
object. You could use that to verify that your code computes md5 checksums for DOM nodes the same way the detector does.
Learn more about the Conflict Detection API.
Reminder! Don’t Leave the Oven or the Conflict Detector On!
Don’t forget to remove the conflict detector script when you’re done. If you enabled it through your kit, it will automatically expire soon. If you’ve added the conflict detector yourself, remove it once you are finished so it doesn’t get deployed to production.