A hovering effect that impacts both an SVG icon and text within an HTML link element

Imagine you have the following HTML structure:

<a href="#">
 <svg class="icon">
 <!-- SVG content -->
 </svg>
 Link text
</a>

And this CSS styling:

a:hover {
  color: #0074D9;
}

.icon:hover {
  fill: #0074D9;
}

Now, the goal is to create a hover effect that changes the color of both the icon and the text when hovering over the entire a element.

Here's an example similar to what you might see on the Instapaper website:

Currently, with the given markup and styles, I'm only able to achieve this effect in Chrome:

Hovering over the text doesn't impact the icon, but hovering over the icon does work:

While it may seem like a simple task, after some unsuccessful attempts, it's clear that something crucial is missing.

Answer №1

After submitting my question, I stumbled upon the solution here on Stack Overflow.

In essence, I needed to "adjust the color of the icon class contained within a hovered a element".

The following code snippet did the trick for me:

a:hover .icon {
  fill: #0074D9;  
}

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

Is it possible to have a combination of a static container height and a dynamically sized container?

Is it possible to have two <div> containers, one with a fixed height and the second one below being dynamic in size to fill up the rest of the viewport? If there is overflow inside the dynamic container, scrollbars should appear within that containe ...

Can a Textmate snippet be activated using a Regex pattern instead of just a specific character?

Hey there, I've been spending a lot of time working with CSS recently, and I have to admit that constantly typing "px" after every width, height, margin, etc., is starting to get on my nerves. I find myself refining pixel values in Firebug quite ofte ...

I must break free! Angular's $sce is failing to manage links to audio files (Strict Contextual Escaping)

I have successfully implemented Angular and $sce in my project to handle HTML special characters and link video files in the database to a video player. However, I am facing issues connecting the HTML audio player to audio files stored in the same database ...

Static express fails to load CSS files from the main folder

When my app is loaded from a url like: server.com/pdf/12345, it tries to find static files at GET /pdf/12345/assets/css/stylesheet.css and returns a 404 error. I've been struggling to get it to search for the files in /public/assets instead. I've ...

Bug with the button and text input feature in Firefox

I am facing a strange issue where the button and input have the same CSS (except for the background), but Firefox is displaying them differently. This problem does not occur in IE or Chrome. #searchInput { width: 80%; margin: 0 auto; display: ...

Python Selenium tutorial: Navigating inner scrollbars on websites

Struggling to implement scrolling within a container with its own scrollbar. Various methods have been attempted, but none have succeeded or met the desired standard. Here is the HTML code snippet of the scrollbar: <div id="mCSB_2_dragger_vertical ...

Using GWT without an internet connection to display JSON data in an HTML format

Here's the scenario: I am utilizing GWT as an offline application. I have stored my data in JSON format in a JS file, which is then included in the HTML page of the GWT application. The JSON data is accessed using JSNI methods. The issue I am facing ...

Tips on deactivating automatic email client-specific content (such as Gmail or Outlook) in your emails

I have inserted the following code => <span style="font-size:12px;"><b>Name:</b></span></font><font size="1"><span style="font-size:12px;">Pratik</span> However, when viewed in a browser (such as Outlook ...

Tips on how to align text vertically within an @Html.TextAreaFor

Is there a way to vertically center text in a @Html.TextAreaFor? Below is the HTML code: <table class="width100percent padding0Margin0"> <tr class="height35"> <td class="width150"> Descrip ...

Finding the value of a radio button dynamically created by jQuery

I am having an issue retrieving the value of a radio button that is generated using jQuery. I suspect there may be some problems with event handling. Below is my code: HTML <div id="divOption1"></div> The jQuery script to generate t ...

Customizing Magento Options: Exploring ways to tweak the design of product options

I'm attempting to stack the options vertically rather than side by side. I'm struggling to figure out which code I need to adjust, my brain seems to be failing me on this one. Should I make changes to the product-options-wrapper? ...

Issue with Bootstrap 4's vertical alignment center in flex layout not functioning as expected

Im using Bootstrap 4 to create a responsive layout with 3 columns that adjust order, width, and horizontal alignment based on screen size. Everything is functioning correctly except for the horizontal center alignment of the images on screens smaller than ...

The page becomes unresponsive once a window is closed

My process in selenium is outlined as follows: Accessing a webpage Clicking on a tab Clicking on the add button within the tab to open a window Closing the window Attempting to click on the same tab again Although I can successfully complete steps 1 to 4 ...

Increase the spacing between elements in a row using Bootstrap's margin utility

I am working with Bootstrap and have a row class containing three different elements. I want to create a margin of 20px between each element in the row container while keeping them all on the same line. Currently, when I add a margin class with a parameter ...

Delayed retrieval of a JavaScript file

I'm facing a peculiar issue that has me stumped. I have two .js files that I include in the body of my webpage. The first one is jQuery (32.4KB) downloaded from Google's servers, while the second one is also jQuery (same file size) downloaded fro ...

When inline-block elements wrap onto a new line, they expand to full width

Upon my realization, an inline-block element will expand to 100% width if there are more child elements than can fit on one line: <div style="background-color:red;padding:5px"> <div style="display:inline-block;background-color:green;padding:5 ...

What is the best way to make a span's background color stretch to 100% width?

Is there a way to make the background of a span element stretch to the full width of its parent container? Just to Clarify I understand that using divs is an option, but it feels more like a workaround than a genuine solution to the issue. (di ...

Encountering an error: Unable to access property 'main' as it is undefined in MUI v5

I encountered an issue while trying to implement page pagination for my Table following a tutorial. The error message I see in my browser is: Uncaught TypeError: Cannot read property 'main' of undefined at ButtonRoot.ownerState.ownerState ...

Issue with Html CSS search bar: the icon is unresponsive when clicked

I've encountered an issue with a website template that includes a search form with an icon in the text field. https://i.sstatic.net/F0gLs.png When users enter a value and press 'Enter', the form functions as expected. However, clicking on ...

Tips for removing the extra space below an element within a details element

When I have a details element and try to set its height to 100%, there is some space below the element, even when tested with a textarea and div. https://i.sstatic.net/zZszF.png I am specifically talking about the space between the red border of the .log ...