CSS fails to style links

Apologies in advance for the seemingly trivial and highly specific question, but I'm really struggling with this one.

I'm attempting to style two <li> elements that are nested within a

<nav><ul><li><a href="">text</a></li></ul></nav>
. Additionally, I want to make the footer appear white.

I can't seem to pinpoint what's causing the issue in my code, preventing it from rendering correctly.

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
html,
body {
  height: 100vh;
  font-family: 'Roboto', sans-serif;
  color: #ffffff;
  background-color: #0e2a47;
}

.Titlebanner {
  display: block;
  width: 50%;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  border-color: #48ffd5;
  border-radius: 1em;
}

.Titlebanner h1>a {
  color: #ffffff;
  font-weight: 700;
  font-size: 2em;
  text-decoration: none;
  border-bottom: 2px solid #48ffd5;
}

ul {
  display: flex;
  flex-direction: row;
  justify-content: center;
  list-style: none;
  padding: 0;
}

nav li {
  list-style: none;
  display: flex;
  margin: 2em;
  padding: 1em;
  border-radius: 1em;
  border: 2px solid #48ffd5;
}


/* --------------Here is what I’ve tried to modify but doesn’t work-------*/

a:hover,
a:visited,
a:link,
a:active {
  color: white;
  text-decoration: none;
}


/*---------------------------------------*/

.body {
  display: flex;
  flex-direction: row;
}

.ranking {
  width: 8%;
  height: 4em;
  background-color: grey;
  align-items: center;
  position: -webkit-sticky;
  position: sticky;
  top: 0.5em;
}

.ranking>ul {
  padding: 0;
  display: flex;
  flex-direction: column;
}

.ranking>ul>li {
  margin: auto
}

.Analysis {
  display: flex;
  flex-direction: row;
  margin: auto;
  width: 80%;
  justify-content: center;
  text-align: justify;
}


/*---------------------- and here for the footer -------*/

footer>a {
  display: block;
  width: 30%;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  color: white;
}


/*-----------------------------------------------*/
<body>
  <header>
    <div class="Titlebanner">
      <h1><a href="index.html">Impact of Privacy Policies on Users’ Lives</a></h1>
    </div>
    <!------------- here is the part I’m trying to style----->
    <nav>
      <ul>
        <li><a href="result.html">Results</a></li>
        <li><a href="analysis.html">Analysis</a></li>
      </ul>
    </nav>
    <!----------------------------------------------------->
  </header>

  <div class="body">
    <div class="ranking" id="ranking">
      <ul>
        <li>First Place</li>
        <li>Second Place</li>
      </ul>
    </div>

    <div class="Analysis">
      text
    </div>
  </div>
</body>
<!----------------- and the footer I’m trying to style as well------->

<footer>
  <span class="">
      <a href="">About us</a>
    </span>
</footer>
<!------------------------------------------------------------->

Answer №1

When targeting a link directly within your footer, use footer a or footer > span > a instead of something else.

If your header styling is not applying correctly, it could be due to specificity issues. Try simplifying from header > h1 > a to just header a, and adjust a:hover to header a:hover.

Avoid using capital letters in class names as well.

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

Creating a server-side HTML template: A step-by-step guide

I need to create a consistent layout for all of my website pages using Bootstrap. While I already have a layout designed for a single page, I want to apply the same design across all pages. My initial thought was to utilize Jade for this task, but I want t ...

What causes my favicon to switch back to a server icon when I click on "View Source"?

This website showcases its favicon: link rel="shortcut icon" href="http://www.pathfolios.com/sites/default/files/Untitled-1%20copy%20%281%29.png" type="image/png" The favicon displays correctly when navigating through the site's pages. However, whe ...

What is the reason that the attr function fails to function in this particular scenario?

I want to implement a functionality where clicking on an input field clears its value, but I can't seem to make it work. Here is the HTML code: <input id='input' type="text" name="phppostvar" value="clear this"></input> This i ...

Streamlined Navigation Bar Design for Websites

Struggling with aligning all the navbar options in a single row. Here is an example: https://jsfiddle.net/knyx2u8h/ ` Example Domain <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; char ...

Tips for preserving border-radius while animating the size of an element

I am trying to achieve a carousel indicator animation where the list item pops out to zero radius in a circular shape. However, my current attempt results in the list item animating in a square shape instead. Is there a way to make it appear in a circular ...

Positioning Div at the Bottom of a Interactive Flip Card Using Bootstrap 4

My current project features a creative flip image card created using bootstrap and js. On the back of the card, there is a title, a main text body, and a few small additional pieces of information. My goal is to have these three small bits of information a ...

Incorporate a button into your Django formset application

Working with Django 5, I am in the process of creating a web application for managing a Secret Santa gift exchange project. One issue I'm facing is that formsets are not dynamic, meaning I cannot generate a variable number of forms based on user inpu ...

Displaying arrays in tabular and grid formats using PHP

I am working with an array containing item code, item name, and price details. $arr = array( "101: orange juice - 5.2", "504: hot roll - 6.2", "106: lime juice - 3", "210: mineral water (s) - 2.6", "107: PEACH JUICE - 6.99", "211: ...

What is the best way to send multiple responses from an Express server using res.write and execute a specific action after each write operation?

I currently have an active express server that is sending data using res.write() Fetcher.js function fetcher() { console.log("fetcher function called") fetch('/units.html', { method: "POST", body: JSO ...

Tips for efficiently choosing the right element in Python 3 with Selenium

I have a challenge where I need to extract a specific element from a webpage using Python 3 and Selenium. The page contains a lengthy list (consisting of hundreds of items) all formatted similarly like this: https://i.sstatic.net/su2Ug.png Here is the H ...

How come this relative URL is functioning properly?

Recently, I've been experimenting with web crawlers and testing them on various websites. However, I've encountered some sites where the relative URLs don't seem to work as expected. When the browser resolves them, they end up pointing to a ...

Is there a way for me to implement my custom CSS design within the Material UI Textfield component?

I have a project in Next.js where I need to create a registration form with custom styles. The issue I'm facing is that I'm struggling to customize a textField using my own CSS. I attempted to use the makeStyles function, but encountered a proble ...

Angular animation triggered when a specific condition is satisfied

I am working on an animation within my Angular application @Component({ selector: 'app-portfolio', templateUrl: 'portfolio.page.html', styleUrls: ['portfolio.page.scss'], animations: [ trigger('slideInOut&apo ...

I'm having trouble understanding why my Javascript validation suddenly stopped functioning. Can anyone assist me in troubleshooting this issue?

I have been working on this webpage for a school project for a few days, and it was running smoothly until about 10 minutes ago. The only change I made was adding an extra JavaScript validation. Now, when I try to register by clicking the "register" butt ...

Having difficulties in loading the CSS file for my real-time chat application built with Express and Socket.io

Hi everyone, I've been struggling with an issue for the past couple of days where I can't seem to load my CSS for my Express app. If anyone has a solution, I would greatly appreciate the help. Below is my server.js code: const express = requir ...

Is it possible to generate a triangular attachment below a div element?

My designer sent me a unique design and I'm wondering if it's possible to replicate using HTML, CSS, or JavaScript? https://i.stack.imgur.com/spB71.png I believe it can be done with CSS by creating a separate div positioned absolutely under the ...

What is the best way to troubleshoot an unresponsive button element to determine the listeners it has?

In a previous situation, I encountered an issue with the event modifier of a nested b-input not working as expected. To resolve this, I had to add .native because I was interacting with a component: b-dropdown(text="Actions") b-drop ...

Creating a dynamic CSS hover animation for an input element with jQuery to ensure compatibility with Microsoft Edge

I am facing an issue where I have a row of six to nine switches with the <input type="checkbox"> element, and each switch animates when hovered over. In this animation, the knob slides down, and both the knob and track fill with colors or gradients. ...

Ensure that the standard icon is properly aligned with the stacked icon of equal size

Seeking guidance on aligning two icons to be the same size. Here is what I'm aiming for: https://i.sstatic.net/SHuH9.png However, in current development, they appear like this: https://i.sstatic.net/crfdl.png When attempting to resize the stack ic ...

Just starting to learn jquery and I'm struggling with this code, can someone help?

I am trying to move the .icon element to the right and animate it based on its position().left value. Unfortunately, my code is not working as expected and I can't figure out why. It seems like such a simple task! <script> $("li.menu-item").ho ...