Issues with the functionality of customisable list items in a list

I am attempting to customize the appearance of specific list items within a ul element. One li element should be displayed in red font, while another li element should have a hyperlink styled with a different color and an underline rollover effect. The third li element should also have a hyperlink with an underline rollover effect, but maintain the standard link color.

Can anyone provide guidance on how I can achieve this? Thanks in advance for any assistance.

ul.standard-list{
padding:0px 0 50px 00000;
margin:0;
text-align:left;
color:#333;
font-weight:100;
font-family:verdana,arial,"Times New Roman", Times, serif,georgia,serif,helvetica;
font-size:20px;
-webkit-font-smoothing: antialiased; /* subtley makes fonts smoother */
line-height:28px;
}
ul.standard-list a:link{
color:#008CBA;
text-decoration:none;
}
ul.standard-list a:visited{
color:#008CBA;
text-decoration:none;
}
ul.standard-list a:hover{
color:#008CBA;
text-decoration:underline;
}
ul.standard-list li{
list-style-type: none;
line-height:28px;
}
ul.standard-list li:before{
    /* Unicode bullet symbol */
    content: '\2022';
    /* Bullet color */
    color: #008CBA;
    padding-right: 10px;
}
.standard-list.no-list-decoration{
color:red;
}
.standard-list.link-2 a:hover{
text-decoration:underline;
}
<ul class="standard-list">
          <li><a href="http://google.co.uk">linked, underlined in different colour with underline rollover effect</a></li>
          <li class="no-list-decoration">red</li>
          <li class="link-2"><a href="http://google.co.uk">linked, underlined rollover effect but same colour as normal list style</a></li>
          <li>four</li>
          <li>five</li>
    </ul>

Answer №1

You should adjust your CSS to include the necessary spaces:

.standard-list .no-list-decoration{

instead of

.standard-list.no-list-decoration{

Alternatively, you can use

ul.standard-list .no-list-decoration{

The same applies to

.standard-list .link-2 a:hover{

which should be changed to

.standard-list .link-2 a:hover{

Answer №2

Create unique classes to achieve distinct rollover effects for different li tags. One will have a red underline on hover (.link-1) and the other will have an underline on hover but maintain the same color as the normal list style (.link-2). Remember to style them accordingly.

ul.standard-list .link-1 a:hover{
    color:red;
    text-decoration:underline;
}
.standard-list .link-2 a:hover{
    text-decoration:underline;
}

ul.standard-list{
padding:0px 0 50px 00000;
margin:0;
text-align:left;
color:#333;
font-weight:100;
font-family:verdana,arial,"Times New Roman", Times, serif,georgia,serif,helvetica;
font-size:20px;
-webkit-font-smoothing: antialiased; /* subtley makes fonts smoother */
line-height:28px;
}


ul.standard-list a:link{
color:#008CBA;
text-decoration:none;
}
ul.standard-list a:visited{
color:#008CBA;
text-decoration:none;
}
ul.standard-list .link-1 a:hover{
color:red;
text-decoration:underline;
}
ul.standard-list li{
list-style-type: none;
line-height:28px;
}
ul.standard-list li:before{
    /* Unicode bullet symbol */
    content: '\2022';
    /* Bullet color */
    color: #008CBA;
    padding-right: 10px;
}
.standard-list .no-list-decoration{
color:red;
}
.standard-list .link-2 a:hover{
text-decoration:underline;
}
<ul class="standard-list">
          <li class="link-1"><a href="http://google.co.uk">linked, underlined in different colour with underline rollover effect</a></li>
          <li class="no-list-decoration">red</li>
          <li class="link-2"><a href="http://google.co.uk">linked, underlined rollover effect but same colour as normal list style</a></li>
          <li>four</li>
          <li>five</li>
    </ul>

Answer №3

It seems that the color red was not displaying due to a lack of space between the two classes.

ul.standard-list{
padding:0px 0 50px 00000;
margin:0;
text-align:left;
color:#333;
font-weight:100;
font-family:verdana,arial,"Times New Roman", Times, serif,georgia,serif,helvetica;
font-size:20px;
-webkit-font-smoothing: antialiased; /* subtley makes fonts smoother */
line-height:28px;
}
ul.standard-list a:link{
color:#008CBA;
text-decoration:none;
}
ul.standard-list a:visited{
color:#008CBA;
text-decoration:none;
}
ul.standard-list a:hover{
color:#008CBA;
text-decoration:underline;
}
ul.standard-list li{
list-style-type: none;
line-height:28px;
}
ul.standard-list li:before{
    /* Unicode bullet symbol */
    content: '\2022';
    /* Bullet color */
    color: #008CBA;
    padding-right: 10px;
}
.standard-list .no-list-decoration{
color:red;
}
.standard-list .link-2 a:hover{
text-decoration:underline;
}
<ul class="standard-list">
          <li><a href="http://google.co.uk">linked, underlined in different colour with underline rollover effect</a></li>
          <li class="no-list-decoration">red</li>
          <li class="link-2"><a href="http://google.co.uk">linked, underlined rollover effect but same colour as normal list style</a></li>
          <li>four</li>
          <li>five</li>
    </ul>

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

Issue with flexbox max-width property not being applied when resizing the page width

I'm struggling to make a flex box with max and min width properties work properly. When I reduce the page size, it ends up showing blank space instead of resizing. How can I troubleshoot this issue? .parent{ border: 1px solid red; width: 50%; ...

What causes a horizontal line to form when a user enters white space?

I have written a piece of code which seems to be causing an issue when running it. Whenever I input empty spaces, it results in creating a horizontal line. import React, { Component } from 'react'; export default class App extends Component { co ...

Dropdown menu remains unable to open

One of the dropdown menus on my website is not retracting back properly, but only on the contact page where a Google map is displayed. The issue looks like this: I've tried tweaking the CSS code without success. What could I be missing? Should I prov ...

Angular not updating the values in real time

First and foremost, I am utilizing socket.io to emit data. Data is emitted upon connection (so the website does not appear blank) as well as when certain events occur. Upon initial connection or page refresh, everything updates and functions smoothly. Howe ...

Understanding the concept of for loops in JavaScript and incorporating them in CSS styling

Hello there! I initially used this code to draw 12 lines, but now I am looking to incorporate a for loop and implement it in CSS. Can someone please guide me on how to proceed? <!DOCTYPE html> <html> <head> <style> #straigh ...

Is it feasible to utilize a CSS variable within a CSS "background URL" property?

Having trouble setting a base domain for all my pictures in a CSS file. Here's what I've tried: In global.css: :root { --bgd: #C0C0C0; --picdomain: "https://somedomain.com/"; } In s1.css: @import url("global.css"); body { background-co ...

Inline CSS for altering the appearance of text within a DIV container

Within the confines of this DIV element... <div name="layer1" style="background-color:lightblue;"> <hr>Site:Downtown DataCenter Device: 2KBS</hr> </div> Hello there, I am utilizing Inline CSS Styling. Is it possible to make the t ...

Adding CSS stylesheets on-the-fly in JavaFX

I am looking to incorporate a CSS file from the filesystem into my application. The goal is to allow users to dynamically add JavaFX CSS files that can be created by anyone and stored anywhere on their system. I attempted a test scenario to see if adding ...

Strategies for selecting glyphs in SVG fonts based on their Unicode properties

My goal is to extract specific characters from SVG fonts created for music engraving. Music fonts typically include a large collection of characters (> 3500), but I only require a small subset of them for caching glyphs in compressed form to ensure quic ...

What is the best method for enlarging the central image in Owl Carousel?

Could someone help me with implementing Owl Carousel to achieve this design? I have attempted it, but unfortunately, it is not working as expected. Your assistance in fixing the issue would be greatly appreciated. Please find the necessary code below: ...

The performance of the animation on http://responsive-nav.com/ becomes erratic when viewed on Android devices

Recently, I came across a fantastic plugin that works perfectly on regular computer browsers. However, when I tested it on my android phone, the css3 animation for the dropdown appeared choppy and seemed to be dropping frames. Does anyone have suggestions ...

What is the best way to ensure an input field and a button are aligned perfectly within the same div tag and of equal height?

During a recent HTML-CSS project, I encountered an issue where I struggled to ensure that two elements within a div tag were the same height. The elements in question were an input field and a button with an icon. Here is a snippet of the relevant HTML cod ...

Why is only jQuery 3.2.1 or jQuery Mobile 1.4.5 being loaded?

When I load my html file, only jquery or jquery mobile is loading from the head. Changing the order in which they appear in the head causes a switch in which one is loaded. Is this possibly due to a compatibility issue? <head> <title& ...

What is the best way to customize the appearance of the elements in the hamburger menu within a Bootstrap navigation bar?

I have successfully implemented a responsive navbar using Bootstrap 4. When the screen size is large, there are 2 buttons displayed, and when it's small, a hamburger menu appears. [insert image description here][1][insert image description here][2] ...

Changing Images with Button Click in Javascript

I am facing an issue with my buttons that should swap images once clicked. The first two buttons work perfectly, but for the third and fourth buttons, the images do not disappear when clicking another button. Below is the current code in the document head ...

Problem with Express server not fetching or applying public stylesheet

As I delve into the world of serving pages with node, express, and ejs, I encountered an issue with linking a stylesheet to my index.ejs file using a public folder. Despite setting up the link correctly in the HTML code, the styles were not loading when I ...

Please only choose the immediate children of the body element

<body> <div> <div class='container'></div> </div> <div class='container'></div> </body> Is there a way to use jQuery to specifically target the second container div dire ...

What can be used instead of the html5 output tag?

After creating a webpage with a form that includes several "number" input fields, I utilized the html output tag to showcase the results. However, when viewed in MSIE, although the calculations were successfully done, the output tag failed to display the ...

Is there a way to use a single url in Angular for all routing purposes

My app's main page is accessed through this url: http://localhost:4200/ Every time the user clicks on a next button, a new screen is loaded with a different url pattern, examples of which are shown below: http://localhost:4200/screen/static/text/1/0 ...

Changing the description doesn't affect the fixed height of the box - here's how to do it with CSS

Here are the references I used: GetBootstrap Jumbotron CoreUI Base Jumbotron This is how my script looks like: <template> <div class="wrapper"> <div class="animated fadeIn"> <b-card> <b-row v-for="row in ...