SVG Sprite remains functional even after deleting the element

Within my index.shtml, I include the following code:

<object data="icons/svg-sprite.svg" type="image/svg+xml" width="0" height="0" style="display: none;"></object>

Inside my svg-sprite.svg file, the content is as follows:

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" focusable="false">
<defs>
        <symbol id="html_element_group_core" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" focusable="false" x="0px" y="0px" viewBox="0 0 24 24" enable-background="new 0 0 24 24">
        <path d="M12,0C5.369,0,0,5.369,0,12s5.369,12,12,12s12-5.369,12-12S18.631,0,12,0zM12,21.6c-5.298,0-9.6-4.302-9.6-9.6S6.702,2.4,12,2.4s9.6,4.302,9.6,9.6S17.298,21.6,12,21.6zM12,7.2c-2.654,0-4.8,2.146-4.8,4.8s2.146,4.8,4.8,4.8s4.8-2.146,4.8-4.8S14.654,7.2,12,7.2z" />
    </symbol>
    </defs>

Once again referencing my index.shtml, this time with the following snippet:

    <svg class="group_icon svg_icon">
        <use xlink:href="icons/svg-sprite.svg#html_element_group_core"></use>
    </svg>

It's important to note that the use element directly references the icon from the svg-sprite.svg file.

I'm puzzled by the fact that even if I remove the object element, it still functions correctly. Why is this the case? Do I actually need the object tag at all, or is it due to the direct reference within

icons/svg-sprite.svg#html_element_group_core
?

Answer №1

Combining two distinct techniques is causing confusion

xlink:href="icons/svg-sprite.svg#html_element_group_core"
functions as a URI,
loading the external SVG file and showcasing only the Symbol.

Please be aware that using just href is preferable over the outdated xlink: notation.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I have noticed that there are 3 images following the same logical sequence, however only the first 2 images seem to be functioning correctly. Can you help

Update: I have found a solution that works. You can check it out here: https://codepen.io/kristianBan/pen/RwNdRMO I have a scenario with 3 images where clicking on one should give it a red outline while removing any outline from the other two. The first t ...

Comparing flex-fill and flex-grow-1 in Bootstrap: Understanding the distinctions

Can you explain to me what sets apart the flex-fill and flex-grow-1 classes in Bootstrap 4+? According to the documentation, flex-fill is defined as: Fill When applied to sibling elements, the .flex-fill class ensures that they occupy widths equal to the ...

Gin and Golang: Implementing HTML files with CSS styling

I am still learning English, so please bear with me :) My issue is that when using Gin to load HTML, my HTML file contains an import (/stylesheet/index.css), but when I run my app with Gin, it gives an alert that the stylesheet file could not be loaded. ...

Avoid incorporating unicode characters in Angular 4

How can I prevent users from using unicode characters in a text field in my front-end developed with Angular 4 framework? For example: ½ -> U+00BD ('onehalf') ...

Using PHP and an HTML form to input multiple data entries into a MySQL database

I am currently working on a project that involves reading and inserting columns and rows from an HTML form into a MySQL database using PHP. When trying to execute the code, I encountered the following error: Undefined index: maintenance on line 28 Undef ...

Tips for adapting the position of a floating div according to its height and environment

Important Note: The code below utilizes the rubuxa plugin for handling JS sortables. Javascript: function querySelector(expr){return document.querySelector(expr)} var container = querySelector('.ITEST'); var sortable = Sortable.create(container, ...

Show a triangle positioned on the left side of the display

Looking for help with aligning a div to the left side of the screen CSS #nav { position: fixed; height: 50px; width: 50px; display: block; background-color: #000; } This particular div contains an icon that acts as a link HTML <div id="nav"> ...

Trouble with the mobile layout - styling with CSS

Having an issue with the mobile view CSS. Visit: Looking to shift the navigation button to the right and widen the logo without changing its height. Any assistance would be appreciated. Thank you, ...

Ensure YouTube iframe remains visible above all other elements on mobile devices at all times

Currently, my method involves utilizing YouTube for embedding videos and incorporating certain elements that should display on top of the video when clicked on. Regrettably, this functionality operates flawlessly on desktop browsers but encounters issues ...

Stylish CSS: Jagged 3-dimensional rotated text

Have a look at this Codepen to see the issue. As the text moves into the background, more aliasing appears. A screenshot taken in Chrome on macOS (similar appearance in FF & Safari): https://i.sstatic.net/n746I.png I've experimented with different ...

Understanding the float property in CSS

Check out this CSS example: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Jenware | Personalized Gifts</title> <style type="text ...

Tips on revealing the following div using jQuery

Can anyone help me figure out how to reveal the next div with a class of .hide when a Clickbox is clicked? Here is a link to the demo: http://jsfiddle.net/fvuqW/ This is the jQuery code I currently have: $(function(){ $('.form input[type=checkb ...

Discover additional and subtract options

I am trying to implement a "See more" and "See less" button functionality for my list items inside an unordered list using the code below, but it is not working as intended. $(document).ready(function() { var list = $(".partners__ul li"); var numTo ...

Achieving Height Diversity in Floating HTML Divs

I have a unique set of dynamically generated divs inside a container div with different heights. <div id="container"> <div id='d1'>Varying content...</div> <div id='d2'>Varying content...</div> < ...

Effortlessly alternate between dual-column and single-column layouts using CSS

Creating a basic two column layout with fixed widths is my current project. <div id='box'> <div id='ontop'>Ontop</div> <div id='column1'>Column1</div> <div id='column2'&g ...

Are there any images included in the WebResponse being downloaded?

I need to download HTML efficiently in order to parse it with minimal bandwidth consumption. Here is a snippet of my code: if (!String.IsNullOrEmpty(siteAddress)) webReq = WebRequest.Create(siteAddress) WebResponse webRes ...

The Cordova minification tool fails to compress files within the browser platform

I recently installed the cordova-minify plugin to compress the javascript code in my Cordova app. When I tried running the command: cordova build browser An output message appears: cordova-minify STARTING - minifying your js, css, html, and images. ...

What is the proper way to incorporate html entities in my specific situation?

In my application, I am attempting to incorporate double macron characters. My current method involves using the &#862; entity, like this: t&#862;t, which results in t͞t. However, I have encountered issues with reliability, as sometimes the ...

When the Model popup is activated, it is essential for elements to have an adequate color contrast

Our team is utilizing the axe dev tool for accessibility testing. We encountered an issue where elements behind a model popup (Kendo React model with position: absolute) were displaying insufficient color contrast errors. Upon changing the absolute positio ...

What is the reason behind text underline being disabled when using "hidden: overflow" in CSS?

I have a long text string that I want to auto-shorten using CSS with text-overflow: ellipsis, but it's removing the underline from my link. Here is the code: NORMAL .link { font-weight: bold; cursor: pointer; color: black; text-decorat ...