A custom icon in Bootstrap is a user-added graphic symbol that is not part of the default Bootstrap icon set. It helps personalize the design by using unique images or SVGs.
Click to reveal answer
beginner
How do you add a custom SVG icon in Bootstrap?
You add a custom SVG icon by including the SVG code directly in your HTML or linking an external SVG file, then styling it with Bootstrap classes or custom CSS.
Click to reveal answer
intermediate
Why use <svg> instead of <img> for custom icons?
Using <svg> allows you to style and scale the icon easily with CSS, keeps it sharp on all screen sizes, and lets you animate parts of the icon if needed.
Click to reveal answer
beginner
What Bootstrap utility classes help with icon sizing and spacing?
Classes like fs-1 to fs-6 control font size, and spacing classes like me-2 (margin-end) or ms-2 (margin-start) help position icons nicely.
Click to reveal answer
intermediate
How to ensure custom icons are accessible?
Add aria-label or role="img" with descriptive text, so screen readers can describe the icon meaning to users with disabilities.
Click to reveal answer
Which HTML element is best for embedding a scalable custom icon in Bootstrap?
A<icon>
B<svg>
C<img>
D<div>
✗ Incorrect
The element allows scalable, styleable vector icons, which is ideal for custom icons.
What Bootstrap class would you use to add horizontal space after an icon?
Amb-2
Bms-2
Cmt-2
Dme-2
✗ Incorrect
The class me-2 adds margin to the end (right in LTR languages), creating horizontal space after the icon.
How can you make a custom icon accessible to screen readers?
AUse only decorative icons
BUse only colors to convey meaning
CAdd aria-label with a description
DHide the icon with display:none
✗ Incorrect
Adding aria-label provides a text description for screen readers, improving accessibility.
Which is NOT a benefit of using SVG for custom icons?
ALoads faster than PNG always
BScales without losing quality
CCan be styled with CSS
DSupports animation
✗ Incorrect
SVGs do not always load faster than PNGs; loading speed depends on file size and complexity.
Where should you place the SVG code for a custom icon in your Bootstrap project?
ADirectly in HTML where the icon appears
BOnly in external CSS files
CInside JavaScript files only
DIn the <footer> tag
✗ Incorrect
Embedding SVG directly in HTML allows easy styling and control where the icon appears.
Explain how to add a custom SVG icon to a Bootstrap webpage and make it accessible.
Think about where the SVG goes, how to style it, and how to help screen readers.
You got /3 concepts.
Describe the advantages of using SVG icons over image files like PNG or JPG in Bootstrap projects.
Consider how SVG behaves visually and technically compared to raster images.
You got /4 concepts.
Practice
(1/5)
1. What is the main reason to use custom icons in Bootstrap projects?
easy
A. To increase page loading time
B. To make the website look unique and clear
C. To replace all text with images
D. To avoid using any CSS styles
Solution
Step 1: Understand the purpose of custom icons
Custom icons help make a website visually unique and improve clarity by showing meaningful symbols.
Step 2: Compare options
Options B, C, and D do not describe benefits of custom icons. Only To make the website look unique and clear correctly states the main reason.
Final Answer:
To make the website look unique and clear -> Option B
Quick Check:
Custom icons improve uniqueness and clarity = A [OK]
Hint: Custom icons improve look and clarity, not performance [OK]
Common Mistakes:
Thinking custom icons slow down the site
Confusing icons with replacing text content
Ignoring the visual clarity benefit
2. Which of the following is the correct way to include a custom SVG icon inline in Bootstrap HTML?
easy
A. <svg class='bi'><use xlink:href='#icon-name' /></svg>
B. <img src='icon.svg' class='bi'>
C. <icon name='custom-icon' />
D. <svg href='icon.svg' class='icon'></svg>
Solution
Step 1: Identify correct SVG inline usage
Bootstrap uses <svg> with <use> referencing an icon ID inside an SVG sprite.
Step 2: Check each option
<svg class='bi'><use xlink:href='#icon-name' /></svg> uses <svg> and <use xlink:href='#icon-name' /> which is correct. <img src='icon.svg' class='bi'> uses <img> which is not inline SVG. <icon name='custom-icon' /> uses a non-standard <icon> tag. <svg href='icon.svg' class='icon'></svg> incorrectly uses href on <svg>.
Final Answer:
<svg class='bi'><use xlink:href='#icon-name' /></svg> -> Option A
Quick Check:
Inline SVG with <use> = B [OK]
Hint: Inline SVG uses <svg> with <use xlink:href> [OK]
Common Mistakes:
Using <img> instead of inline SVG
Using non-standard tags like <icon>
Incorrect attributes on <svg> tag
3. What will be the visual result of this code snippet?
The aria-label is present but role='img' is missing, which is needed for screen readers to treat SVG as an image.
Step 2: Validate other attributes
Using href is valid in modern browsers (SVG2), so no error there. Width and height with '1em' are valid CSS units. The class attribute is allowed on SVG.
Final Answer:
Missing role='img' attribute for accessibility -> Option C
Quick Check:
SVG needs role='img' for accessibility = C [OK]
Hint: Always add role='img' with aria-label on SVG icons [OK]
Common Mistakes:
Confusing href and xlink:href usage
Thinking class attribute is invalid on SVG
Ignoring accessibility role attribute
5. You want to add a custom icon to a Bootstrap button that changes color on hover and is accessible. Which combination of code and classes is best?
hard
A. <button class='btn btn-primary'><svg class='bi'><use xlink:href='#send-fill'/></svg> Send</button>
B. <button class='btn btn-primary'><svg class='bi text-primary' role='img' aria-label='Send'><use xlink:href='#send-fill'/></svg> Send</button>
C. <button class='btn btn-primary'><img src='send.svg' alt='Send icon'> Send</button>
D. <button class='btn btn-primary'><svg class='bi text-white' role='img' aria-label='Send'><use xlink:href='#send-fill'/></svg> Send</button>
Solution
Step 1: Check color and accessibility
<button class='btn btn-primary'><svg class='bi text-white' role='img' aria-label='Send'><use xlink:href='#send-fill'/></svg> Send</button> uses text-white on the SVG so the icon color contrasts well on the blue button background. It also includes role='img' and aria-label for accessibility.
Step 2: Compare other options
<button class='btn btn-primary'><svg class='bi text-primary' role='img' aria-label='Send'><use xlink:href='#send-fill'/></svg> Send</button> uses text-primary which is blue, so icon won't contrast on blue button. <button class='btn btn-primary'><img src='send.svg' alt='Send icon'> Send</button> uses an image without inline SVG, losing Bootstrap styling. <button class='btn btn-primary'><svg class='bi'><use xlink:href='#send-fill'/></svg> Send</button> lacks color class and accessibility attributes.
Final Answer:
Button with SVG icon using text-white and accessibility attributes -> Option D
Quick Check:
Accessible icon with visible color on button = A [OK]
Hint: Use text-white on icon inside colored buttons for contrast [OK]
Common Mistakes:
Using icon color same as button background
Skipping role and aria-label on SVG
Using img instead of inline SVG for Bootstrap icons
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.