Q
How can you reference an external SVG file within an HTML document for displaying an icon?

Answer & Solution

Answer: Option B
Solution:
External SVG files are referenced and displayed in HTML using the <use> element with the SVG file path and the desired icon's ID.
Related Questions on Average

What is the purpose of using SVG sprite sheets for icons in web development?

A). Combine multiple SVG icons into a single file for performance

B). Embed SVG icons directly into HTML for faster loading

C). Use inline SVG code for flexibility

D). Increase file size for better quality

Which attribute is used in SVG <use> elements to reference a specific icon within an external SVG file?

A). xlink:href

B). src

C). href

D). file

What is the purpose of using external SVG files for icons in web development?

A). Code reusability and maintenance

B). Increased file size

C). Inline styling options

D). Compatibility issues

How can you apply CSS styles to an SVG icon referenced using the <use> element?

A). Apply styles directly to the <use> element

B). Apply styles to the referenced SVG file

C). Apply styles to the <svg> element containing the <use> element

D). Apply styles to the parent container of the <svg> element

How can you add a title to an SVG icon for accessibility purposes?

A). Using the <desc> element

B). Using the <span> element

C). Using the <title> element

D). Using the <header> element

How can you embed an inline SVG icon directly into an HTML document?

A). Using the <svg> element

B). Using the <img> element

C). Using the <div> element

D). Using the <span> element

How can you create a hover effect for an SVG icon using CSS?

A). Apply :hover pseudo-class to the SVG element

B). Use JavaScript for hover effects

C). Add a <hover> attribute to the SVG icon

D). Apply a class on hover using JavaScript

What technique can be used to change the color of an SVG icon on user interaction?

A). Apply CSS styles on hover or click events

B). Use JavaScript to dynamically change the SVG's color

C). Embed multiple versions of the SVG with different colors

D). Apply inline styles to the SVG icon

What is the recommended approach for optimizing SVG icons for web use?

A). Minimize file size, remove unnecessary code, and optimize paths

B). Increase file size for better quality

C). Use inline styles for all SVG elements

D). Embed external CSS files into SVG

What is the advantage of using CSS for styling SVG icons instead of inline styles?

A). Easier maintenance and consistent styling

B). Better compatibility with older browsers

C). Faster loading times

D). Increased file size