What is the process for changing text to red when hovering over it in a nested list?

a {
  color:black;
}

a:hover {
  color:red;
}
<ol>
          <a href="#"><li>Main1</li></a>
          <a href="#"><li>Main2</li>
          <a href="#"><li>Main3
            <ol>
              <a href="#"><li>Sub1</li></a>
              <a href="#"><li>Sub2</li></a>
              <a href="#"><li>Sub3</li></a>
            </ol>
          </li></a>

          <a href="#"><li>Main4</li></a>
          <a href="#"><li>Main5</li></a>

          <a href="#"><li>Main6</li></a>
        </ol>

By hovering over each item, the color of the item will change to red. However, there are some sub-items under Main3 and when I hover over Main3 only Main3 turns red. How can I make the number "3" in front of Main3 also turn red?

Answer №1

Have you had a chance to test this out in your CSS file?

ul li a, ol li a {text-decoration: none;}

ul li a:hover, ol li a:hover {color: #E8001F;}

Additionally, do you think it should be done the opposite way?

  • Location 1
  • Location 2
  • Location 3

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

The text-decoration is here to stay

Currently, I am facing an issue with the customization of a wordpress theme related to the styling of links within posts. Although I have tried to change the color and remove underlining using CSS rules, I am unsuccessful so far: a, .entry-meta a, entry-c ...

The navigation menu that usually appears on mobile devices is surfacing on desktop screens instead - update: images now

I have recently been working on my website juniorgoldreport.com, which was created using WordPress. The plugin I am using specifically for the mobile nav bar is The functionality and ease of use of this plugin are incredible. The setting to show the toolb ...

Is it possible to use the same identifier for both the name and id attributes in HTML?

In the world of coding, the "name" attribute is often used in server-side programming to send name/value pairs in requests. On the other hand, the "id" attribute is commonly utilized in client-side programming such as Javascript and CSS. However, both att ...

Refreshing the Dropdown Menu with Jquery

Looking for a way to create a reusable dropdown menu using css/jquery? Check out this codepen: https://codepen.io/anon/pen/NxXXPg Is there a method to reset the 'active' status when clicking on a blank space or another html element? Here's ...

Leveraging CSS attribute selectors within JSX using TypeScript

With pure HTML/CSS, I can achieve the following: <div color="red"> red </div> <div color="yellow"> yellow </div> div[color="red"] { color: red; } div[color="yellow"] { color: yellow; ...

Struggling to make JavaScript read JSON data from an HTML file

I am currently working on developing a word search game using django. One of the tasks I need to accomplish is checking whether the entered word exists in a dictionary. To achieve this, I have been converting a python dictionary into JSON format with json. ...

Load data into a table in HTML after a successful jQuery event

I'm facing an issue with populating an HTML table dynamically. Below is the structure of my HTML table: <table class="flexme" id="table" border="1"> <thead> <tr> <th width="100">Usuario</th> <th wid ...

Switch up the animation based on the state in AngularJS

In my AngularJS application, I have implemented CSS animations for transitioning between states. The animations involve sliding content from left to right with specific timings and transforms. .content.ng-enter, .content.ng-leave { -webkit-animation-t ...

Vue JS encounters difficulties when attempting to lazy load various images from a randomized image URL

I've implemented a code snippet for lazy loading images with different URLs: <img src="https://source.unsplash.com/1600x900/?hotel,booking.com?v=1" loading="lazy" /> <img src="https://source.unsplash.com/1600x900/?hot ...

Creating borders around Material UI grid items can be achieved by applying a border style to the

import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; import Paper from '@material-ui/core/Paper'; import Grid from '@material-ui/core/Grid'; const useStyles = makeStyles((theme) => ({ ...

Eliminating unnecessary whitespace between the bottom of the document and an element

I have a HTML page that when scrolled should limit scroll to the document height. It must not exceed the bottom of an element. Here is a screenshot for better understanding: https://i.stack.imgur.com/RaVg8.jpg The scrolling should be limited after the En ...

Completed Animation with Callback in AngularJS CSS

Currently working with AngularJS and hoping to receive a notification upon completion of an animation. I am aware that this can be achieved with javascript animations such as myApp.animation(...), but I'm intrigued if there is an alternative method wi ...

Safari iOS does not display any background for Buttons

Encountering an unusual problem with buttons on iOS devices specifically in Safari browser - the background color isn't being applied like it is on Desktop and Android devices. Here are the CSS properties for the button: export const Button = styled.b ...

Challenges with dynamically adding rows using jQuery

I am trying to create a dynamic form that allows users to select a project and then populates tasks based on the selected project from a database query. The user can then enter hours for each task, which are updated based on the project id and task id comb ...

A simple demo showcasing interactive HTML pages using Django and AJAX

In my search for answers, I came across the following helpful posts: How to Reload table data in Django without refreshing the page Tutorial on Django dynamic HTML table refresh with AJAX Despite the insights from these posts, I am still facing chal ...

Inserting images into a MySQL database using Ajax and file uploads

I am using JQuery Mobile, PHP, and Ajax to upload an image and insert it into a database, but I am facing an issue with inserting the image's name in the database. The result in the database shows "C:fakepathLighthouse.jpg", but I only want to insert ...

transforming a div to behave similarly to an iframe

I am trying to load content from my page into a div element using the following function: function loadmypage(DIV, pageURL) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } e ...

The login page allows entry of any password

I'm running a xamp-based webserver with an attendance system installed. I have 10 registered users who are supposed to log in individually to enter their attendance. However, there seems to be an issue on the login page where any password is accepted ...

Customize the layout of menu icon in HTML/CSS using FlexBox Grid

Recently, I have encountered an issue with the position of a menu icon on my website. The icon is displayed when the window reaches a certain size, but it is not aligned properly on the right side of the site. Ideally, I would like to use the "right" prope ...

Adjust the remaining choices according to the dropdown selection

I am looking to dynamically adjust other dropdown menus based on the selection in a specific dropdown. For example, when the main dropdown is changed to "Change," I want the other dropdowns to automatically select the "Refused to Answer" option. HTML < ...