Mouse cursor does not display as a pointer when utilizing an SVG image on Internet Explorer

Consider this html:

<a href="http://www.wikipedia.com">
    <object data="http://upload.wikimedia.org/wikipedia/en/4/4a/Commons-logo.svg" type="image/svg+xml">
        <img src="http://herdeirodocaos.files.wordpress.com/2007/11/wikipedia-logo.jpg" alt="Logo" />
    </object>
</a>

This css is also applied:

a {
    display: block;
}
object, img {
    width: 200px;
    height: 200px;
}

object:hover {
    cursor: pointer;
}

Explore the JsFiddle link

Is it puzzling why the cursor doesn't transform into a pointer (hand) when hovering over the image only in Internet Explorer?

Any thoughts on how to fix this issue?

Answer №1

Consider incorporating the following CSS snippet:

element{
    pointer-events: none;
}

Answer №2

In summary: The issue with IE8 occurs because it cannot interpret the object and instead places the image in its position. Your description of the error seems to be the opposite of what is actually happening :-)

I am certain that the behavior you are describing is quite the reverse - only in IE 8 is the cursor set to pointer, while in my other browsers (FF, Chrome, IE 10...) the cursor defaults to default, resembling an arrow.

My theory is that IE8 struggles to understand SVG (as versions prior to 9 do not support SVG) and therefore shows the image as part of a link - assigning it the appropriate cursor, pointer, redundantly defined in your CSS. On the contrary, other browsers are able to interpret the object correctly and display it without applying the desired cursor, as the element type is designated as object (similar to placing a flash movie, like a YouTube video, within the a element).

One more thing to note: using the :hover selector is unnecessary; the cursor will only display over the element when it's directly hovered upon.

Edit: Erik's comment provides a concise explanation (included here for quick reference):

To resolve this issue, consider placing the cursor rule inside the svg tag where the events will be directed for tags. Events will not "bubble" up to the parent document. Alternatively, you can use an iframe referencing the svg, such as: jsfiddle.net/Mw8JX

Answer №3

Dealing with the same issue, I was able to solve it by including cursor:pointer in the link's styling. Here's a snippet of the code:

a { cursor:pointer }

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

Displaying WordPress plugin queries in a linked file

I have been working on developing a custom WordPress plugin that involves querying a database based on user input and then displaying the results in an HTML file with links. While I have managed to successfully display the HTML page, I am facing an issue w ...

Strange spacing appears after image tags

My efforts to remove the space (red) between the <img> and the <div> have been unsuccessful. I have minimized it as much as possible. After researching similar threads, it seems that whitespace or newlines between inline-box elements can cause ...

Detecting click events in D3 for multiple SVG elements within a single webpage

My webpage includes two SVG images inserted using D3.js. I am able to add click events to the SVGs that are directly appended to the body. However, I have encountered an issue with another "floating" div positioned above the first SVG, where I append a dif ...

Converting an HTML page to PDF with Angular using jsPdf and Html2Canvas

[1st img of pdf generated with position -182, 0, image 208,298 ][1]Converting an HTML page to PDF in Angular 8+ using jspdf and Html2canvas has been a challenge. Only half of the page is successfully converted into PDF due to a scaling issue. Printing th ...

Activate all chosen CSS circles

I'm currently working on creating a progress bar using CSS circles. The idea is that when you click on each circle in sequence (1, 2, 3), all three circles and the line connecting them will fill up with red color. If you then go back (3, 2, 1), the co ...

How to optimize PHP scripts by using a single MySQL query instead of loops?

Below are the tables I am working with... Locations __________________________________________________________ ID Location Region Country 1 Newmarket Ontario Canada 2 Barrie ...

Using TypeScript with Angular UI Router for managing nested named views in the application

Hey there! I am new to typescript and have a bit of experience with Angular. Lately, I've been struggling to make a common angular-ui-router setup work with typescript. I have a nested named views structure that just doesn't seem to load correctl ...

Another option for replacing <BR> tags with CSS styling

I am currently utilizing the br tag to insert line breaks in my website's faq section. Although the output is accurate, I'm exploring alternatives like implementing linebreak through CSS to enhance responsiveness. During my research, I came acros ...

"Challenges with Full-Width Dropdowns in Multi-level Mega Menus

I am currently attempting to design a multi-level mega menu that spans the full width of the screen, while keeping the content within it restricted to a maximum width of 1240px. I have managed to set the content to the maximum width, but I am facing challe ...

How come the subitems of a second-level nested list do not appear when hovering over a hyperlink?

Show "News" in French when hovering over the French option. ul#topmenu li a#HyperLink:hover ul { background-color: pink; display: list-item; } <ul id="topmenu"> <li class="langHorzMenu"> <a href="#" id="HyperLink">French</ ...

Rearrange information when the textarea is adjusted in size

One issue I am facing is that when I resize the textarea in my form, the content below the textarea does not move along with it. How can I ensure that the content moves accordingly when resizing the textarea? <form name="contactform" method="post" ...

I find myself unable to write any code using my Visual Studio Code

I'm facing an issue where I can't write any code on my Visual Studio Code. Despite following all the recommendations on the official website, I haven't been able to resolve the problem. More information here Here are the changes I have tri ...

Finding the div associated with the element that triggered an event

I've recently launched a website that allows users to post questions and receive responses from others. Each question is housed in a div, which then contains another div with the CSS property of display: none. Within the main div, there's a butt ...

The function document.getElementById is unable to select multiple elements simultaneously

I've been tackling a loading issue. I have a visible div, #loading, and multiple hidden divs, #message. I also have a JavaScript function. function loading() { setTimeout(function() { document.getElementById("loading").style.display = " ...

Are there any improved methods for optimizing the CSS in my Next.js project?

Currently, I'm immersed in a project using Next.js and styling it with CSS in JS (ReactJSS). Upon inspecting the page source, I noticed that there are over 4000 lines of CSS for a single page, which is not ideal for performance. To provide context, l ...

What is the best way to set the width of a w2grid to 100%

Has anyone tried using w2grid before? I'm having trouble figuring out how to make it fill its container 100%. Here's the HTML snippet: <div id="a" style="width:100%"> <!-- top left container--> <div>This ...

Leverage variable as an expression when utilizing ng-include

Here is an example of working code: <div ng-include src="'Test.html'"></div> However, this code does not work: <div ng-include src="ctrl.URL"></div> (When ctrl.URL is set to "Test.html"). I have also tried setting it t ...

When styled with an id, the DIV element does not inherit styles from a CSS class

I seem to be facing an issue with the code below, possibly due to using both class and id in the same div. Despite knowing they are meant to work together. For more information: Can I use DIV class and ID together in CSS? .PB { position: relative; ...

Attempting to utilize Bootstrap for containing text inside of a background

<div class="container"> <div class="row"> <div class="col-lg-9"> <h2 style="font-family:times-new-roman">BIOGRAPHY</h2> <div id="demo" class="collapse"> <p> Isaac Newton (4 January 1643 – 31 March 1727) w ...

The Django dilemma: Determining the right balance between using templates and letting code generate HTML

When working with Django templates, I wonder if it's better to have template "subroutines" or generate HTML within the code for certain cases. For instance, imagine a template with multiple lists of names that need to be converted into select element ...