Display a text decoration effect when hovering over a division

Is there a way to change the color of a link when hovering over the entire div it's in, rather than just the link itself? Can this effect be achieved using only HTML & CSS?

For instance, if I had (jsfidde), how could I make the link turn blue when hovering over the gray area and not the actual link?

<style>
    #parent {
        background-color: gray;
        height: 100px;
        width: 200px;
    }
    #parent img {
        margin: auto;
        line-height: 90px;
    }
    #caption a {
        text-decoration: none;
        color: black;
    }
    #caption a:hover {
        color: blue;
    }
</style>
<div id="parent">
    <img src="http://www.cedexis.com/images/icons/32-social.png?1389641973" />
    <div id="caption"> <a href="jsfiddle.net">This is a caption</a>

    </div>
</div>

Answer №1

#parent:hover a {
    color: blue;
}

Answer №3

For example, check out this link: http://jsfiddle.net/techsin/7MLSb/2/

#container:hover a {
    text-decoration: underline;
    color: red;
}

Whenever the container is hovered over, all links inside it will be underlined and turn red.

Answer №4

Implement the following code snippet:

#main:hover #description a {
    text-decoration: underline;
}

Rather than this alternative:

#description a:hover {
    text-decoration: underline;
}

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 been working on creating a hangman game, and although I have figured out the logic behind it, I am experiencing an issue where it is not functioning properly. After inspect

I am currently working on a basic hangman game using only HTML and JavaScript. I have the logic in place, but it doesn't seem to be functioning correctly. When I inspected the element, it showed an error saying 'undefined toUppercase.' As a ...

The method of stamping masonry is not encircling

I recently discovered a new method in Masonry 3 called "stamp" that allows you to fix an element in place. However, I am finding that it is not working as expected. Check out this example from David DeSandro: http://codepen.io/desandro/pen/wKpjs Initial ...

Guide on repetitively invoking a function in jQuery

I am looking to create a continuous fade in and out effect on a picture with a delay using jQuery. I attempted the following code but it is not working as expected. $(document).ready( setTimeout( function () { $("#ssio").fadeToggle(1000); ...

What's the best way to create flying text effects - using CSS or JavaScript

Looking for a way to enhance the user experience of my shopping cart on Android and iPhone/iPod, I want to implement a feature similar to the iTunes Store where the price flies down to the total when a purchase is made. Since I use jQuery (not UI) on this ...

What is causing the bullets for the unordered list to appear before the items are inserted into the list?

Can you explain why the bullets are showing up before the list items are added? <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>To Do List</title> </head> <body> ...

employing rowspan functionality within a JavaScript application

How can I achieve a table layout where the first two columns are fixed for only one row and the remaining rows are repeated 7 times? Additionally, is there a way to make the bottom border of the last row thicker? Check out the expected table for reference. ...

Creating a circular array of raycast directions with HTML Canvas 2D

I'm currently working on implementing raycasting in typescript with HTML Canvas 2D based on the tutorial from this video: https://youtu.be/TOEi6T2mtHo. However, I've encountered an issue where the rays being cast consistently point in a single di ...

How can I show the remaining paragraph text upon clicking a button in a responsive manner using CSS and JavaScript?

I want to add a nice animation effect to the height of my text when a button is clicked. I've managed to achieve this by setting a height: 30px with overflow: hidden initially, and then toggling a class with height: 300px. However, I'm facing an ...

Optimizing the appearance of an unordered horizontal list in the most effective manner

When attempting to make lists horizontal and hide default bullets, is it necessary to apply {display:inline} and {float:left} to both the <li> tags or would just one of these properties suffice? <ul> <li><a href="#">First item< ...

The command `python3 manage.py findstatic` is unable to locate the static file

I have been struggling to incorporate static files into my project, but the CSS is not loading. I tried using findstatic but Django is unable to locate any static directory: https://i.sstatic.net/jRgzx.png https://i.sstatic.net/7VG0x.png In a different pr ...

Ways to establish a specific minimum width for a container and disregard small breakpoints in Bootstrap 5

I want to set a fixed minimum width for a container while ignoring small sizes like sm and xs. Basically, when the screen size is less than 960px, I want the width to be fixed and only display a scroll. This is the code I have: <div class="contain ...

I've had enough with Facebook Like Box problems - I'm at the end

Setting up a Like Box feature on my website, found at , has been a challenge. The Facebook Page associated with the site can be located at: I have experimented with various methods such as iFrame and FBML but each time I attempt to click the "like" button ...

What is the method for creating two separate columns that can scroll independently?

I am faced with a challenge involving a modal that contains two columns. My goal is to make these columns scrollable independently of each other while ensuring the scrollbar remains hidden. Thus far, I have managed to make the row scrollable with a hidden ...

If the background image on a div is not visible, then the alt text of the

Here is my unique HTML code consisting of a single div and an image positioned outside the div. <div runat="server" id="ProductThumbnail" style="width:140px;height:140px;position:relative;background-position:center;background-repeat:no-repeat;"> ...

What are the various ways to incorporate material graphic elements on an HTML static webpage?

Currently, I am working on creating a static website that will be stored on CDs and USB sticks. This website serves as a manual for a specific product. I am considering using a graphic framework like Onsen UI, but I have found that I prefer Material UI. ...

Having trouble populating form with JSON data. It's not appearing

Currently, I am experimenting with jsfiddle to troubleshoot an issue that is possibly unrelated to React.JS. The problem involves populating form fields with data stored in a JSON file. You can view the fiddle here: https://jsfiddle.net/vp5kLxgs/ I am op ...

The best way to perfectly align my gridview in HTML and CSS

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" Width="1000px" AllowPaging="True" PageSize="8" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnPageIndexChanging="GridView1_PageIndexChanging" OnRowCanc ...

Viewing an image from a local file on a web browser

I am currently working on a project where I want the user to be able to select a local image that will then be displayed on the page. As someone who is new to web development, I did a lot of research and found some helpful information on StackOverflow. I t ...

jQuery tooltip box not functioning correctly

When the mouse enters on li a, the tooltip box (class .show_tooltip) is appearing on the left. I want each tooltip box to display just above or to the left of the link that the mouse is on. The links need to stay on the right as they are now, so please do ...

What is the best way to assign various classes to individual elements depending on their content?

HTML <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-401 dt-mega-menu mega-auto-width mega-column-3"> <a href='#' data-level='1'> <i class="logo-png dnld-logo"></i> ...