Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Font Awesome Icons

Font Awesome Icons

Font Awesome is a popular icon font library used in web design and development.

Font Awesome contains a set of vector icons that can be easily invoked and used via CSS; they can be customized in size, color, shadow, and so on.

Font Awesome was originally an open-source project created by Dave Gandy, aimed at providing a flexible, easy-to-use, and extensible set of icons to replace traditional image icons.

Font Awesome has released many versions; the current mainstream one is Font Awesome 6 , Font Awesome 5 and Font Awesome 4, all versions can be referenced at:https://fontawesome.com/versions.

This site's tests use Font Awesome 4, icon list: https://fontawesome.com/v4/icons/.

To use Font Awesome icons, please add the following line to the relevant part of your HTML page:

1. Recommended CDN in China:

<

link

rel

=

"

stylesheet

"

href

=

"

https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css

"

2. Recommended CDN overseas

<

link

rel

=

"

stylesheet

"

href

=

"

https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css

"

3. Download directly to local

Download

Note: It is not recommended to download and install it; simply reference the CDN file in the head of your HTML document.

Note: This tutorial uses version 4.7.0.

You can use the prefix 'fa' and the icon name to place Font Awesome icons.

Example

<

!

DOCTYPE

html

<

html

<

head

<

link

rel

=

"

stylesheet

"

href

=

"

https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css

"

head

<

body

<

i

class

=

"

fa fa-car

"

i

<

i

class

=

"

fa fa-car

"

style

=

"

font-size:48px;

"

i

<

i

class

=

"

fa fa-car

"

style

=

"

font-size:60px;color:red;

"

i

body

html

Result:

Try it »

Click the "Try it" button to view the online example

Font Awesome is designed to be used with inline elements. and The element is widely used for icons.

Also note that if you change the font size or color of the icon container, the icon will change.


Large Icons

The classes fa-lg (increase 33%), fa-2x, fa-3x, fa-4x, or fa-5x are used to increase the icon size relative to its container.

Example

<

!

DOCTYPE

html

<

html

<

head

<

link

rel

=

"

stylesheet

"

href

=

"

https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css

"

head

<

body

<

i

class

=

"

fa fa-car fa-lg

"

i

<

i

class

=

"

fa fa-car fa-2x

"

i

<

i

class

=

"

fa fa-car fa-3x

"

i

<

i

class

=

"

fa fa-car fa-4x

"

i

<

i

class

=

"

fa fa-car fa-5x

"

i

body

html

Result:

Try it »

Tip: If your icon is cut off at the top and bottom, increase the line height.


List Icons

The fa-ul and fa-li classes are used to replace the default prefix in unordered lists.

Example

<

ul

class

=

"

fa-ul

"

<

li

<

i

class

=

"

fa-li fa fa-check-square

"

i

List icons

li

<

li

<

i

class

=

"

fa-li fa fa-spinner fa-spin

"

i

List icons

li

<

li

<

i

class

=

"

fa-li fa fa-square

"

i

List icons

li

ul

Result:

  • **List icons
  • **List icons
  • **List icons

Try it »


Bordered and Pulled Icons

The fa-border, fa-pull-right, or fa-pull-left classes are used for pulled quotes or article icons.

Example

<

i

class

=

"

fa fa-quote-left fa-3x fa-pull-left fa-border

"

i

Runoob Tutorial -- learn not only technology, but also dreams!!!

<

br

Runoob Tutorial -- learn not only technology, but also dreams!!!

<

br

Runoob Tutorial -- learn not only technology, but also dreams!!!

<

br

Runoob Tutorial -- learn not only technology, but also dreams!!!

Result:

Runoob Tutorial -- learn not only technology, but also dreams!!!

Runoob Tutorial -- learn not only technology, but also dreams!!!

Runoob Tutorial -- learn not only technology, but also dreams!!!

Runoob Tutorial -- learn not only technology, but also dreams!!!

Try it »


Animated Icons

The fa-spin class makes the icon rotate, and the fa-pulse class makes the icon rotate in 8 steps per cycle.

Example

<

i

class

=

"

fa fa-spinner fa-spin

"

i

<

i

class

=

"

fa fa-circle-o-notch fa-spin

"

i

<

i

class

=

"

fa fa-refresh fa-spin

"

i

<

i

class

=

"

fa fa-cog fa-spin

"

i

<

i

class

=

"

fa fa-spinner fa-pulse

"

i

Result:

Try it »

Note: IE8 and IE9 do not support CSS3 animations.


Rotated and Flipped Icons

The fa-rotate-* and fa-flip-* classes are used to rotate and flip icons.

Example

<

i

class

=

"

fa fa-shield

"

i

<

i

class

=

"

fa fa-shield fa-rotate-90

"

i

<

i

class

=

"

fa fa-shield fa-rotate-180

"

i

<

i

class

=

"

fa fa-shield fa-rotate-270

"

i

<

i

class

=

"

fa fa-shield fa-flip-horizontal

"

i

<

i

class

=

"

fa fa-shield fa-flip-vertical

"

i

Result:

Try it »


Stacked Icons

To stack multiple icons, use the fa-stack class on the parent; the fa-stack-1x class is for regular-sized icons and fa-stack-2x is for larger icons.

The fa-inverse class can be used as an alternative icon color. You can also add a larger icon class to the parent for further size control.

Example

<

span

class

=

"

fa-stack fa-lg

"

<

i

class

=

"

fa fa-circle-thin fa-stack-2x

"

i

<

i

class

=

"

fa fa-twitter fa-stack-1x

"

i

span

fa-twitter on fa-circle-thin

<

br

<

span

class

=

"

fa-stack fa-lg

"

<

i

class

=

"

fa fa-circle fa-stack-2x

"

i

<

i

class

=

"

fa fa-twitter fa-stack-1x fa-inverse

"

i

span

fa-twitter (inverse) on fa-circle

<

br

<

span

class

=

"

fa-stack fa-lg

"

<

i

class

=

"

fa fa-camera fa-stack-1x

"

i

<

i

class

=

"

fa fa-ban fa-stack-2x text-danger

"

style

=

"

color:red;

"

i

span

fa-ban on fa-camera

Result:


fa-twitter on fa-circle-thin


fa-twitter (inverse) on fa-circle


fa-ban on fa-camera

Try it »


Fixed Width Icons

The fa-fw class is used to set icons with a fixed width. This class is very useful when different icon widths deviate from alignment. It is especially suitable for Bootstrap's navigation lists and list groups.

Example

<

div

class

=

"

list-group

"

<

a

href

=

"

"

class

=

"

list-group-item

"

<

i

class

=

"

fa fa-home fa-fw

"

i

Home

a

<

a

href

=

"

"

class

=

"

list-group-item

"

<

i

class

=

"

fa fa-book fa-fw

"

i

Library

a

<

a

href

=

"

"

class

=

"

list-group-item

"

<

i

class

=

"

fa fa-pencil fa-fw

"

i

Applications

a

<

a

href

=

"

"

class

=

"

list-group-item

"

<

i

class

=

"

fa fa-cog fa-fw

"

i

Settings

a

div

Try it »