The icon on a website is handy. They provide meaningful information, providing links to email forms, telephone numbers, maps and more. There are two types of icons first is Decorative icons and second is Semantic icons. The Decorative icons are only being used for visual or branding. If they removed from the page, users still understand and can use the page. The second one is semantic icons. By using this icon you are convey meaning, like buttons, form elements, toggles, etc.
Icons can be added to an HTML page with the help of an icon library. All the icons in the library can be formatted using CSS. They can be customized according to size, color, shadow, etc. You have to put the name of the icon in the class of an HTML element to use it.
Following are types of icon library:
- Font Awesome Icons
- Google Icons
- Bootstrap Icons
Font Awesome Icons
Adding Icon using CDN Link
You can add font-awesome icons directly by using CDN link. Below code is CDN link.
<link rel=”stylesheet”
href=”https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css”>
Add this code in <head> section. It does not require any downloading or installation.
Example:
<!DOCTYPE>
<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-cloud” style=”font-size:30px;”></i>
<i class=”fa fa-car” style=”font-size:30px;”></i>
<i class=”fa fa-file” style=”font-size:30px;”></i>
</body>
</html>
Adding Icon using Files Download
Simply, download the font-awesome files and copy that files in one folder, and give the path name of that folder in your code.
Example:
<!DOCTYPE html>
<html>
<head>
<link rel=”stylesheet” type=”text/css” href=”css/font-awesome.css”/>
<link rel=”stylesheet” type=”text/css” href=”css/all.css”/>
</head>
<body>
<i class=”fas fa-phone-alt”></i>
<i class=”fas fa-coffee”></i>
<i class=”fas fa-gift”></i>
</body>
</html>
In the above example, we give the path name “css/font-awesome.css”. The font-awesome files are located in css file so we give css/font-awesome.
Using Font Awesome Pro
In Font Awesome Pro, a ton of new icons are available. And all are paid.
Following example show, how to add Font Awesome Pro.
Example:
<!DOCTYPE html>
<head>
<link rel=”stylesheet” href=”https://pro.fontawesome.com/releases/v5.8.2/css/all.css” integrity=”sha384-xVVam1KS4+Qt2OrFa+VdRUoXygyKIuNWUUUBZYv+n27STsJ7oDOHJgfF0bNKLMJF” crossorigin=”anonymous”>
</head>
<body>
<i class=”fal fa-globe-americas”></i>
</body>
</html>
Google Icons
To set Google icons following link is add in <head> section.
<link rel=”stylesheet” href=”https://fonts.googleapis.com/icon?family=Material+Icons”>
Example:
<!DOCTYPE html>
<html>
<head>
<link rel=”stylesheet” href=”https://fonts.googleapis.com/icon?family=Material+Icons”>
</head>
<body>
<i class=”material-icons”>cloud</i>
<i class=”material-icons”>computer</i>
<i class=”material-icons”>attachment</i>
</body>
</html>
Bootstrap Icons
To set Bootstrap Icons add following link in <head> section.
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”>
Example:
<!DOCTYPE html>
<html>
<head>
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”>
</head>
<body>
<i class=”glyphicon glyphicon-cloud”></i>
<i class=”glyphicon glyphicon-remove”></i>
<i class=”glyphicon glyphicon-user”></i>
<i class=”glyphicon glyphicon-envelope”></i>
<i class=”glyphicon glyphicon-thumbs-up”></i>
</body>
</html>