How to use font awesome icons in bootstrap 4?
April 29, 2022Hi Friends 👋,
Welcome To aGuideHub! ❤️
Today, I am going to show you. How to use font awesome icons in bootstrap 4 with code example.
To use Font Awesome icons, add the following to your HTML page (No downloading or installation is required):
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
Then, add the name of the icon class to any inline HTML element (like <i> or <span>)
:
Example:
Let’s look at the following example to understand how it basically works:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous"></head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<body>
<div class="container">
<h1>My Icons <i class="fa fa-cloud"></i></h1>
<p>An icon along with some text: <i class="fas fa-thumbs-up"></i></p>
</div>
<div class="container">
<p>Others:</p>
<i class="fas fa-cloud"></i>
<i class="fas fa-band-aid"></i>
<i class="fas fa-car"></i>
<i class="fas fa-file"></i>
<i class="fas fa-clock"></i>
</div>
</body>
</html>
Check the output of the above code example.
All the best 👍