CHAPTER 16
CSS Icons
Learn how icons can be styled and displayed in modern websites using CSS and icon libraries.
01. What is CSS Icons?
Icons are visual symbols used to communicate actions or information.
CSS can control the size, color and spacing of icons.
Icon libraries such as Font Awesome provide ready-made icons.
02. Syntax
.icon {
font-size: 30px;
color: #2563eb;
}
03. Example
CSS / HTML Example
AIFA Coding Lab
<!DOCTYPE html>
<html>
<head>
<style>
.icon {
font-size: 40px;
color: #2563eb;
}
</style>
</head>
<body>
<div class="icon">
★
</div>
</body>
</html>
04. Important Points
✓
Icons should support the content rather than replace important text.
✓
CSS controls icon size and color.
✓
Use consistent icon sizes throughout a design.
✓
Make interactive icons accessible.
05. Common Mistakes
⚠
Using too many icons.
⚠
Using icons without understanding their meaning.
⚠
Making icons too small to see.
⚠
Ignoring accessibility for icon-only buttons.
06. Real World Use
Icons are widely used in navigation menus, dashboards, social media buttons, feature cards and mobile interfaces.
Ready to Practice? 🚀
Open the AIFA CSS Editor and practice this chapter live.
Try It Yourself →
Practice Exercise
Create an Icon Card
Create a card containing a star symbol, heading and paragraph. Style the icon using CSS.