Unable to utilize CSS for my navigation menu

I need some help tweaking my navigation bar using CSS, but for some reason, the changes I make in the CSS file are not reflecting on the actual page.

Below is the HTML and CSS code snippets:

HTML:

<!DOCTYPE html>
<html lang=en>
<head>
<title>Sketch</title>
<meta charset = "UTF-8">
<link rel="stylesheet" type="text/css" href="css/general.css">
</head>
<body>

<div id="nav">
<ul>
<li><a href="index.html">Home</a></li>
</div>

</body>

And here is my CSS:

.nav{
width:100%;
height:30px;
text-align:center;
background:#f1f1f1;
}

Answer №1

make sure to use #nav as opposed to .nav

Answer №2

Incorrectly done, it should be #nav instead of .nav

Answer №3

Your navigation div is currently using an ID (#).

You can either switch it to a class or update your CSS like this:

.nav{
width:100%; <-- By the way, this is not necessary as all divs are already 100% width by default
height:30px;
text-align:center;
background:#f1f1f1;
}

Answer №4

Your style has been defined using the class .net instead of the id #nav, so make sure to update your code to match the correct node:

#nav{
  width:100%;
  height:30px;
  text-align:center;
  background:#f1f1f1;
}

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

Javascript Error: Attempting to setAttributeNode on a checkbox that is invalid

I encountered an error and I'm unsure how to fix it, could you please assist me? Here's the code snippet: var ls_contextid1 = JSON.parse(localStorage.getItem('completedArray')) || []; for (var i = 0; i < ls_contextid1.length; ...

Top technique for mirroring a website

Recently, I created a directory for a client's website. The site is fully operational, but the client would like a replicated version for testing and learning purposes. To create a full replica of his website, it will require hours of work to change ...

Save HTML Form data to an excel spreadsheet

I'm currently working on an online form for a friend's business, where truck drivers have to input their driving details such as time, location, and post-drive cleaning. One of my responsibilities is generating an Excel file from the MySQL databa ...

The button should only be visible when the input is selected, but it should vanish when a different button within the form is

Having an issue with displaying a button when an input field is in focus. The "Cancel" button should appear when a user interacts with a search bar. I initially used addEventListener for input click/focus to achieve this, but ran into a problem: on mobile ...

The vertical tab layout in HTML and CSS is experiencing an issue where the active tab is not being shown above the

Currently, I am developing a web page featuring vertical tabs where each tab corresponds to an image and some content. However, the problem lies in the fact that the active tab is not displaying above the image as expected. In my attempt to resolve this i ...

Using Vue.js to alter the CSS class property

I am exploring Vue.js and looking to modify a CSS class property. Here is the HTML code utilizing the specified class: <div class="customTimer"></div> Here is the corresponding CSS code: .customTimer { width: 100%; height: 1 ...

Using RMarkdown to incorporate custom CSS styling in your documents

Having some trouble with my HTML report created from RMarkdown and applying CSS. The browser version displays correctly, but when printed, the styling doesn't come through. Below is an example of the RMarkdown code: --- title: "Table" output: html_ ...

Obtain array buffer from NodeJS to capture frames from a video file

My current goal is to extract frames from a video in node without relying on a video tag. I am utilizing openvg-canvas for this task, which allows me to print images and use the canvas API functionalities successfully. The challenge lies in the fact that ...

The footer is not extending all the way to the bottom when using a flex layout

While working on my website, I attempted to create a sticky footer. To achieve this, I used JavaScript to dynamically generate the <footer> element in order to keep it at the bottom of the page at different screen widths. My goal was to append the f ...

show certain DIVs based on the URL

Is it possible to dynamically display different sections based on the URL? My event website has 3 subevents, and I'd like to show the date of each event in the navigation bar for their respective URLs. <div id="us" class="us-web-date">&nbs ...

What could be causing checked="checked" to fail validation in JavaScript?

I'm feeling a bit puzzled about this issue. Here's the HTML code I have - <input type="radio" id="20577091" name="q_engine" value="20577091" style="position: absolute; opacity:0;" checked="checked" /> and here is the corresponding JavaScr ...

Even after utilizing box sizing, additional margins are still contributing to the overall width calculation

Having an issue where the margin of my elements is affecting their total width, even with the box-sizing: border-box property in place. There are 2 elements - a sidebar and main content div - that stack neatly until margins are added and the sidebar moves ...

Ancient queries carry the weight of time

Extremely ancient, very old, incredibly aged beyond belief ...

Images in the center with a div overlay on top

I'm attempting to place a div or span on top of an image that is positioned above another image. Both images are centered and resized to fit. The height of my images is greater than the width, but they are not set at a fixed size. I want the div to pe ...

Steps to adjust paragraph and heading alignment through media query

I've been attempting to modify the alignment of the paragraph and heading utilizing a media query to ensure responsiveness. Despite my efforts with max-width, margin, and padding, I have not achieved the desired outcome. .about-background h2 { m ...

Get rid of the "clear field" X button for IE11 on Windows 8

After trying out the suggestions provided in Remove IE10's "clear field" X button on certain inputs? .someinput::-ms-clear { display: none; } I successfully removed the X button on IE 11 running on Windows 7, but unfortunately it didn&a ...

When trying to include an external class that extends Pane in a main class in JavaFX, simply adding it may not achieve the

My primary class is as follows: public class Digital_Analog_Clock_Beta_1 extends Application { @Override public void start(Stage primaryStage) { double outerBoxWidth = 500, outerBoxHeight = outerBoxWidth / 2.5; Rectangle outerB ...

Images are not being successfully retrieved by Express.static from the public folder

Recently, it seems that Express is having trouble pulling images from the image folder in the public directory, even though it can successfully retrieve the styles.css file located in the css folder within the same public directory. The public directory c ...

Tips for positioning a delete button at the start of the row I am transferring to a different table

Displayed below are the contents of the initial table. <% for(int i = 0; i < result.length; i++) { %> <tr id='player-listing-<%=i %>'> <td style="vertical-align: top;"><button onclick="myFunction2(<%=i%> ...

How can you center a webpage and make it occupy 60% of the screen?

I was attempting to design a website where the main content takes up 60% of the body. This is what I tried initially: body { align-items: center; text-align: left; justify-content: center; width: 60%; } Unfortunately, this approach did not work ...