The presence of element hr within element ul is not permitted in this particular context. Additional errors from this subtree will not be displayed

Here is the code snippet that I have been working on recently:

Originally, I had an "hr" tag directly included in my code which worked perfectly but caused a site validation error. So, I made some changes to the code as shown below:

<nav>
            <ul>
<li id="one"><a href="#HOME" id="a" class="active">HOME</a></li>
                            <li id="two"><a href="#ABOUT" id="b">ABOUT</a></li>
<li id="three"><a href="#SERVICE" id="c">SERVICE</a></li>
<li id="four"><a href="#COLLECTIONS" id="d">COLLECTION</a></li>
<li id="five"><a href="#CONTACT" id="e">CONTACT</a></li>
                          
            <hr/>               
</ul>
            </nav>

body{background:#CCCCCC;}
    nav{width:100%;margin:0 10px;padding: 38px 0;}
    nav li{padding:0;}
    nav ul li{display: inline;text-align: center;}
    nav a{display: inline-block;width: 15%;padding: .75rem 0;margin: 0;text-decoration: none;font-family:'leelawadeeregular';font-size: 18px;      color:#e81b64;}
    #one a:hover,.active,#two a:hover,#three a:hover,#four a:hover,#five a:hover{color:#ffffff;}
    #two:hover ~ hr {margin-left:18%;text-decoration:underline;}
    #three:hover ~ hr {margin-left:33.5%;text-decoration:underline;}
    #four:hover ~ hr {margin-left:48.5%;text-decoration:underline;}
    #five:hover ~ hr {margin-left:64%;text-decoration:underline;}
    nav hr {height: .25rem;width:10%;margin:0px 0px;background:#e81b64;border: none;transition: .3s ease-in-out;}
<nav>
                <ul>
    <li id="one"><a href="#HOME" id="a" class="active">HOME</a></li>
                                <li id="two"><a href="#ABOUT" id="b">ABOUT</a></li>
    <li id="three"><a href="#SERVICE" id="c">SERVICE</a></li>
    <li id="four"><a href="#COLLECTIONS" id="d">COLLECTION</a></li>
    <li id="five"><a href="#CONTACT" id="e">CONTACT</a></li>
                              
               <li> <hr/></li>
    </ul>
                </nav>

After making these adjustments, the site validation error has been resolved. However, I am now facing an issue with the CSS animation for the sliding underline not working properly. I would appreciate any help or solutions you can provide.

Answer №1

A requirement is to incorporate the li element into your CSS code in this manner:

    #two:hover ~ li hr {margin-left:18%;text-decoration:underline;}
    #three:hover ~ li hr {margin-left:33.5%;text-decoration:underline;}
    #four:hover ~ li hr {margin-left:48.5%;text-decoration:underline;}
    #five:hover ~ li hr {margin-left:64%;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

How can you modify a specific field using a modal form in Django?

Managing a form to track the entry and exit times of individuals in different areas can sometimes lead to discrepancies. For instance, if someone forgets to "leave" an area before entering a new one, a prompt is shown asking for an "estimate" of the time t ...

Is it possible to change a Material UI style without resorting to an HOC?

Is there any method to modify the styling of a Material UI component without the need to create an entirely new component using withStyles()? For example, if I am currently displaying the following and simply want to adjust the color of the "Delete" label ...

Utilizing jQuery to Toggle Visibility in Form Elements

When I'm working with a form that has multiple fields, one of them is hidden using Jquery based on user selection. However, when I try to submit the form after filling it out, the hidden field and its data are still included in the submission. How can ...

What is the best way to use PHP strip_tags to filter out HTML and Script tags while keeping XML untouched?

I have been using the strip_tags() function in PHP to get rid of HTML tags from my text area input and to eliminate < script > tags for security reasons. However, I have run into an issue where the function ends up removing benign XML tags that are ...

How to Make a Div Element Expand to Fill Unknown Space?

I have a box with the word "Test" inside it. I need to adjust its width to be 100% of its containing div, but I'm unsure about how to do this without using Javascript. The example in the jsFiddle linked below demonstrates what I am trying to achieve. ...

Having trouble with jQuery UI draggable when using jQueryUI version 1.12.1?

Currently, I am diving into the world of jQuery UI. However, I am facing an issue with dragging the boxes that I have created using a combination of HTML and CSS. My setup includes HTML5 and CSS3 alongside jQuery version 1.12.1. Any suggestions or help wou ...

Removing outlines on <p> <a> or <div> elements with Ionic and Angular seems to be a challenging task

Hey there, I’m currently working on my application which includes a login page. I've implemented a “Forgotten password ?” link, but no matter what I try, like using .class and :focus {outline: none}, I still see a yellow square around the item. ...

jQuery code tailored specifically for desktop use

Hello, I could use some assistance with a jquery script. I have been able to accomplish what I need using a jquery script, but I would like it to only work on desktops and be disabled on tablets and mobile devices. The script I am currently using is as fo ...

When using React, I noticed that adding a new product causes its attributes to change after adding another product with different attributes on the same page

Imagine you are browsing the product page for a Nike T-shirt. You select black color and size S, adding it to your cart. The cart now shows 1 Nike T-SHIRT with attributes color: black, size: S. However, if you then switch to white color and size M on the ...

Is there a way to determine if my great-grandfather has a class attribute that includes a specific word?

Looking for some assistance with my HTML code snippet: <div class='one two three and etc.'> <div> <div> <div class='my_target'> </div> </div> ...

Is there a way for the React select component to adjust its width automatically based on the label size?

After defining a React select component, it looks like this: <FormControl> <InputLabel id="demo-simple-select-label">Age</InputLabel> <Select labelId="demo-simple-select-label" id=&quo ...

Experience the classic game of rock-paper-scissors brought to life through JavaScript and HTML,

I've been working on a rock, paper, scissors game in JavaScript and I'm struggling to get the wins and losses to register correctly. The game keeps resulting in a draw even though I've checked my code multiple times. It's frustrating be ...

basic file not functioning properly

So I am currently developing a straightforward script to assign the value " ...php?answer=1" only if the java is enabled. It so happens that I have made some progress on this... <script language="text/javascript"> document.form.answer.value=1; < ...

The IDs and classes of HTML elements

I have two different implementations of a livechat script. On my sandbox site, the livechat is fixed to the bottom right of the page and scrolls with the window. However, on my live site (where this specific code comes from), it is attached to the footer. ...

Ways to place a png image on top of a video background

How can I overlay a PNG over my background video without it appearing behind? I attempted to use z-index, but the video disappears when changing the position from relative to absolute or fixed. Here is the HTML and CSS code: <div id="page2"> &l ...

Ajax - Trouble with Updating DIV Content

As a beginner in AJAX, I am encountering difficulties creating a simple AJAX program. My goal is to have a button that, when clicked, changes the text of the div below it. Despite numerous attempts, I have not been able to identify the issue. Below is the ...

Retrieve a compilation of Whole Foods locations through the use of rvest

I want to retrieve a list of Whole Foods stores using the rvest package. I've successfully extracted information from various sources like Wikipedia, FIFA, and Yahoo! Finance using this method. However, in this case, the table spans multiple pages but ...

Calculating the percentage of two values with jQuery: The Sequel

This is a follow-up from the previous successful discussion on jquery: percentage of two numbers Firstly, I want to express my gratitude for the prompt support provided in the previous post. Now, I am looking to enhance my script further. My goal is to ca ...

Adjust the overall cost according to the quantity using jQuery or JavaScript

I'm currently working on a project that involves input fields for Product Price, Quantity Form Field, and displaying the Total price. My goal is to have the Total price automatically update based on the product price and quantity with jQuery. I am loo ...

Hide Table field display in HTML / ASP.NET

I have recently taken over a web application that was developed using ASP.NET. This app generates a table of query results from a database, with all fields appearing as text except for the "Url" column which is displayed as a hyperlink (see code below). If ...