What's new
HTML Forums | An HTML and CSS Coding Community

Welcome to HTMLForums; home of web development discussion! Please sign in or register your free account to get involved. Once registered you will be able to connect with other members, send and receive private messages, reply to topics and create your very own. Our registration process is hassle-free and takes no time at all!

width: 100%; not taking up 100% of the width my screen?

CreeperBob16

New member
I've scoured countless other forums to find an answer to this question, but none have helped. I'm completely new to HTML and CSS, just started learning yesterday, and I'm trying to make a top Navbar for my website, and I want the bar to take up the entire width of the screen, but there's about 10ish pixels that it doesn't cover, despite setting the width equal to 100% of the screen length. I'll attach my code below, as well as a picture of what it looks like:

HTML:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Home</title>
    <style>
      body {
        background-color: #b3c7d6ff;
      }
      .Header {
        color: #2460a7ff;
        text-align: center;
        font-family: "Georgia";
      }
      .RegText {
        color: #2460a7ff;
        text-align: center;
        font-family: "Georgia";
        white-space: normal;
        padding: 0px 400px;
        font-size: 20px;
      }
      .TopNav {
        overflow: hidden;
        position: fixed;
        background-color: #85b3d1ff;
        top: 0;
        width: 100%;
        height: 4%;
      }
      .Links {
        margin: 0;
        color: #2460a7ff;
        text-align: center;
        text-decoration: none;
        padding: 20px 60px;
        font-size: 25px;
        font-family: "Georgia";
      }
      .TopNav a:hover {
        color: black;
      }
      .Main {
        margin-top: 75px;
        margin-bottom: 75px;
        overflow: hidden;
      }
    </style>
  </head>
  <body>
    <div class="TopNav">
      <a class="Links" href="index.html">Home</a>
      <a class="Links" href="about.html">About</a>
      <a class="Links" href="news.html">News</a>
      <a class="Links" href="contact.html">Contact Us</a>
    </div>
    <div class="Main">
      <h1 class="Header">Home</h1>
      <h2 class="RegText">Lorem ipsum dolor sit amet.</h2>
      <p class="RegText">Dummy Text</p>
    </div>
  </body>
</html>
1635622471004.png
 
Hi, I was facing this issue when I was making a website for me,
The problem was solved when I made changes in body tag..
...................
body {
margin: 0;
padding: 0;
}

....................
Try this, it will surely sort out your issue..
Greetings,
Jim.Wick
 
Back
Top