An SVG icon is a small graphic made with Scalable Vector Graphics. It stays sharp at any size because it uses shapes, not pixels.
Click to reveal answer
beginner
How do you include an SVG icon in Bootstrap?
You can include an SVG icon by using the <svg> element directly or by using Bootstrap Icons library with <svg class='bi'> and referencing the icon name.
Click to reveal answer
beginner
Why use SVG icons instead of image files like PNG?
SVG icons scale without losing quality, have smaller file sizes, and can be styled with CSS easily.
Click to reveal answer
intermediate
How can you change the color of an SVG icon in Bootstrap?
You can change the color by applying CSS styles to the SVG's fill property or by adding Bootstrap text color classes like text-primary.
Click to reveal answer
intermediate
What accessibility feature should you add to SVG icons?
Add aria-hidden='true' if the icon is decorative, or use <title> inside SVG for screen readers if the icon conveys meaning.
Click to reveal answer
What does SVG stand for?
ASimple Visual Guide
BScalable Vector Graphics
CStandard Vector Grid
DStatic Vector Graphic
✗ Incorrect
SVG means Scalable Vector Graphics, which are graphics made from shapes that scale well.
Which HTML element is used to embed an SVG icon?
A<vector>
B<img>
C<icon>
D<svg>
✗ Incorrect
The element is used to embed SVG graphics directly in HTML.
How can you make an SVG icon accessible for screen readers?
AAdd aria-hidden='true' if decorative
BUse only colors to convey meaning
CAvoid adding any ARIA attributes
DUse <img> tag instead
✗ Incorrect
Adding aria-hidden='true' hides decorative icons from screen readers, improving accessibility.
What is a benefit of using SVG icons over PNG images?
APNG images are smaller in file size
BSVG icons cannot be styled with CSS
CSVG icons scale without losing quality
DPNG images are vector-based
✗ Incorrect
SVG icons keep sharp at any size because they are vector graphics.
In Bootstrap, how do you apply a color to an SVG icon?
AUse CSS fill property or Bootstrap text color classes
BChange the SVG file itself only
CUse the <color> HTML tag
DSVG icons cannot have colors changed
✗ Incorrect
You can style SVG icons with CSS fill or Bootstrap text color classes like text-primary.
Explain how to add and style an SVG icon in a Bootstrap webpage.
Think about embedding, coloring, and accessibility.
You got /3 concepts.
Why are SVG icons preferred over traditional image icons in modern web design?
Consider how icons look and behave on different devices.
You got /4 concepts.
Practice
(1/5)
1. What is the main advantage of using SVG icons in Bootstrap over traditional image icons?
easy
A. They scale smoothly without losing quality on any screen size.
B. They load faster because they are always smaller files than images.
C. They automatically add animation effects without extra code.
D. They require no accessibility attributes to be readable.
Solution
Step 1: Understand SVG icon properties
SVG icons are vector graphics, meaning they can scale to any size without losing sharpness or quality.
Step 2: Compare with traditional images
Unlike raster images, SVGs do not pixelate when enlarged, making them ideal for responsive designs.
Final Answer:
They scale smoothly without losing quality on any screen size. -> Option A
Quick Check:
SVG icons scale well = A [OK]
Hint: SVG icons stay sharp at any size, unlike images [OK]
Common Mistakes:
Thinking SVG files are always smaller than images
Assuming SVGs add animations automatically
Ignoring accessibility needs for icons
2. Which of the following is the correct way to set the color of a Bootstrap SVG icon to match surrounding text?
easy
A.
B.
C.
D.
Solution
Step 1: Identify how SVG color matches text
Using fill="currentColor" makes the SVG icon inherit the current text color automatically.
Step 2: Check other options
Options A and D set fixed colors, not dynamic. <svg color="text"></svg> uses an invalid attribute for SVG color.
Final Answer:
<svg fill="currentColor"></svg> -> Option A
Quick Check:
Use fill="currentColor" for text color match [OK]
Hint: Use fill="currentColor" to inherit text color [OK]
Common Mistakes:
Using fixed color codes instead of currentColor
Trying to use CSS color property inside SVG fill
Confusing fill with stroke attribute
3. What will be the visible result of this Bootstrap SVG icon code snippet?
A. Missing <title> element for accessibility despite role and aria-label.
B. Missing fill attribute to set icon color.
C. Missing width and height attributes for sizing.
D. Incorrect use of <path> element inside SVG.
Solution
Step 1: Check SVG accessibility attributes
The SVG has role="img" and aria-label="Search icon", which is good for screen readers.
Step 2: Check for sizing attributes
SVG icons should have width and height attributes to define visible size; missing here means it may not display properly.
Final Answer:
Missing width and height attributes for sizing. -> Option C
Quick Check:
SVG needs width and height to show correctly [OK]
Hint: Always add width and height to SVG icons [OK]
Common Mistakes:
Thinking fill attribute is mandatory for visibility
Assuming aria-label replaces need for sizing
Believing <path> usage is incorrect here
5. You want to use a Bootstrap SVG icon that changes color based on a button's state (normal and hover). Which approach correctly applies this behavior?
hard
A. Wrap SVG in a <span> and toggle different SVG files on hover.
B. Set a fixed fill color on SVG and change it with JavaScript on hover.
C. Use inline styles on SVG to change fill color on hover directly.
D. Set fill="currentColor" on the SVG and change the button's text color with CSS on hover.
Solution
Step 1: Use fill="currentColor" for color inheritance
Setting fill="currentColor" makes the SVG icon inherit the text color of its container.
Step 2: Change button text color on hover with CSS
By changing the button's text color on hover, the SVG icon color changes automatically without extra code.
Final Answer:
Set fill="currentColor" on the SVG and change the button's text color with CSS on hover. -> Option D
Quick Check:
fill="currentColor" + CSS hover color = dynamic icon color [OK]
Hint: Use fill="currentColor" and CSS text color hover [OK]
Common Mistakes:
Using fixed fill colors that don't change on hover
Trying to change SVG fill with inline styles on hover
Replacing SVG files instead of using CSS color changes
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.