CSS Icons


This tutorial will show us how to add CSS icons from an icon library to an HTML page. The library's icons can all be formatted using CSS. They can be altered in terms of size, colours, shadow, and other factors. The icon is a graphic representation that expresses the precise purpose for which it is used and aids in navigation in line with that meaning.

There are three different kinds of icon libraries:

In order to use the predefined icon classes or to customize it using CSS, we will provide the necessary CDN link from the accessible icon library.

In the <head> section, we must include the necessary CDN connection in order to use icons. To add the preset class to HTML, follow these steps:

  • Any inline HTML element should have the icon class name added:
  • It is common practice to include icons using the <i> and <span> components.
  • Each and every CSS icon is a scalable vector icon that can be altered to include the necessary CSS attributes like size, colour, shadow, etc.
  • Note: There is no need to download or install any of the aforementioned libraries.

How Can I Add the Icons?

Using an icon library, like Font Awesome, to add an icon to your HTML website is the simplest option. Any inline HTML element (such as <I> or <span>) should be given the name of the specified icon class.

All of the scalable vector icons in the icon libraries below can be changed using CSS (size, color, shadow, etc.)


1. Fonts Icons: 

Add the following URL inside the <head> section to use Font Awesome Icons.

CDN Link : <link rel="stylesheet"  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>  

Syntax

Example

Preview

2. Google Icons

Add the following URL inside the <head> section to use Google Icons.

CDN Link : <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@48,400,0,0" />

Syntax

Example

Preview

3. Bootstrap Icons

Add the following link inside the <head> section to use Bootstrap Icons.

CDN Link : <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"/>

Syntax

Example

Preview

FAQs

Yes, CSS icons can be used in place of images. They are lightweight, scalable, and customizable. Moreover, they do not require additional HTTP requests, which can improve the page loading speed. CSS icons can be created using various techniques, such as using Unicode characters, SVGs, or icon fonts. They can also be styled and animated using CSS properties like color, size, and transform. Overall, CSS icons are a great alternative to images when it comes to designing a website or application.

Yes, you can easily customize CSS icons. CSS icons are created using CSS code, which is highly customizable. You can change the size, color, and shape of the icon, as well as add animations and other effects to make it unique. Additionally, you can also create your own custom icons using CSS. This allows you to create a consistent design aesthetic across your website or application.

Yes, you can animate CSS icons using CSS3 transitions or keyframe animations. By applying different styles to the icon at different stages of the animation, you can create a wide range of effects, from simple hover effects to complex animations that respond to user interactions. To get started, you can use CSS libraries like Animate.css or create your own animations using CSS code. Just remember to keep your animations simple and subtle, so they don't distract from the overall design of your website or application.