-
Hajipur, Bihar, 844101
Icons in CSS are small graphical elements that improve visual communication on a webpage. They can be implemented using:
Icon Fonts (like Font Awesome)
Inline SVG
Unicode characters
CSS background-images
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<i class="fas fa-home"></i>
<i class="fa-solid fa-envelope"></i>
🟢 These are scalable, color-changeable icons using CSS.
i {
font-size: 24px;
color: darkblue;
margin-right: 10px;
}
<svg width="24" height="24" fill="green" xmlns="http://www.w3.org/2000/svg">
<circle cx="12" cy="12" r="10"/>
</svg>
🟢 Inline SVGs can be styled with fill
, stroke
, width
, height
.
You can use symbols like:
<span class="icon">★</span> <!-- star symbol -->
.icon {
color: gold;
font-size: 20px;
}
<div class="icon-user"></div>
.icon-user {
width: 24px;
height: 24px;
background-image: url('user-icon.png');
background-size: cover;
}
🟢 Useful when using custom PNG/SVG images as icons.
Q1. Add a home icon using Font Awesome.
Q2. Create a delete (trash) icon and style it red.
Q3. Use an inline SVG circle and color it blue.
Q4. Add a star symbol using Unicode.
Q5. Display a user icon as a background image in a div.
Q6. Increase the size of icons on hover.
Q7. Add margin between icon and text.
Q8. Style all <i>
icons to have size 20px and grey color.
Q9. Use a heart icon beside a button label.
Q10. Add an envelope icon before email text.
Q1: What is Font Awesome?
Q2: Which tag is commonly used for icon fonts?
Q3: Which property changes icon color (font icons)?
Q4: What does ★ display?
Q5: How can you resize Font Awesome icons?
Q6: Which icon method allows fill and stroke styling?
Q7: How do you apply hover effect on icons?
Q8: Which method uses a background image as an icon?
Q9: What is the purpose of fa-solid in Font Awesome?
Q10: Which attribute is NOT used in inline SVG?