Basic Use - Font Awesome
Basic Use - Font Awesome
fontawesome.com/how-to-use/on-the-web/referencing-icons/basic-use
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
Style Availability Prefix Example Rendering
1/5
Style
Style Availability Prefix Example Rendering
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:
2/5
have options and solutions for subsetting icons, we aren't comfortable considering
ligatures for Web Fonts + CSS.
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.
You can also use style classes that match your in-use icon styles
.fas { ... }
.far { ... }
.fal { ... }
.fad { ... }
.fab { ... }
3/5
Styling Case Recommended Selector
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">
.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>
4/5
5/5