Body becomes overwhelmed by the presence of white space when margins are reduced to zero

I am puzzled by this issue because I have checked the developer tools and can't find anything causing the body to extend beyond the white space. The only thing that appears over the whitespace is when I hover my mouse over the HTML in the source code using the developer element tool.

Even though I have set the body margin to 0, I still can't understand why there is white space present.

Does anyone have any insights into what might be causing this?

<body>
    <header class="header">
        <div class="header_wrap">
          <span class="nav-btn"></span>
            <ul class="nav_list">
              <a href="/"><li>Home</li></a>
              <a href="Spray-Foam-Insulation-Material-Suppliers"><li>Spray Foam Insulation</li></a>
              <a href="Portable-Spray-Foam-Kits"><li>Portable Spray Foam Kits</li></a>
              <a href="Polyurea"><li>Polyurea</li></a>
              <a href="Personal-protective-equipment"><li>Personal Protective Equipment</li></a>
              <a href="Spray-Foam-Equipment-Financing"><li>Financing</li></a>
              <a href="Contact-us"><li>Contact us</li></a>
            </ul>
         </div>
    </header>
    <div id="lower-header">
        <div id="logo-wrap">
            <a href="/"><img src="http://sprayfoamequipmentinsider.com/images/SFEI Logo & CSS/Spray Foam equipment insider 3.jpg" id="header-logo1"></a>
            <a href="PMC-spray-foam-equipment"><img src="http://sprayfoamequipmentinsider.com/images/Contractor Images/top ad.png" id="header-logo2"></a>
        </div>
        <div id="topnav">
          <ul>
            <a href="Spray-Foam-Parts-Repairs-Techs"><li class="last">TECH/PARTS/REPAIRS</li></a>
            <a href="Spray-Foam-school"><li>SPRAY FOAM SCHOOL</li></a>
            <a href="Used-For-sale-Spray-Foam-Insulation-Rigs-Machines"><li>USED/BUY/SELL</li></a>
            <a href="Spray-Foam-Rigs"><li>SPRAY FOAM RIGS</li></a>
            <a href="Spray-Foam-equipment"><li>SPRAY FOAM EQUIPMENT</li></a>
          </ul>
        </div>
        <br class="clear" />
     </div>

body{margin:0; padding:0; font-size:13px; font-family:Georgia, "Times New Roman", Times, serif; color:#666666; background-color:#FFFFFF;}

.header {
    margin: 0;
    background-color: #333;
    height: 50px;
}
.header_wrap {
    text-align: center;
    margin: 0 auto;
    position: relative;
}
.nav-btn {
    display: none;
}
.nav_list {
    text-decoration: none;
    background: #333;
    color: #FFF;
    list-style: none;
    position: relative;
    z-index: 1;
}
.nav_list > a {
    display: inline-block;
    padding: 15px 12px;
    text-decoration: none;
    transition: ease-in-out .5s;
}
.nav_list > a:first-child {
    padding-left: 0px;
    margin: 0;
}

.nav_list > a > li {
    text-decoration: none;
    font-size: 1.1em;
    color: #FFF;
}

#topbar {
    display:block;
    position:relative;
    width:960px;
    margin:0 auto;
}
/* ----------------------------------------------Header------------------------------------- */

#lower-header {
    margin: 0 auto;
    padding: 10px 0 20px;
    z-index: 1;
    color: #666666; 
    background: #000000; 
    border-bottom: 1px solid #363636;
    width: 100%;
    overflow: hidden;
}
#logo-wrap {
    width: 960px;
    margin: 0 auto;
}
#header-logo1 {
    float: left;
    width: 400px;
    height: 93px;
}
#header-logo2 {
    float: right;
    width: 310px;
    height: 75px;
}
#header-logo1, #header-logo2 { 
    border: none;
}
/*#lower-header h1, #header p, #header ul{margin:0; padding:0; list-style:none; line-height:normal;}*/

#topnav {
    float: left;
    padding-top: 22px;
    width: 100%;
    text-align: center;
    font-size: 1.1em;
    background: #000000;
    font-family: Georgia, "Times New Roman", Times, serif;
}
#topnav li {
    display: inline-block;
    padding: 10px 12px 0 12px;
    border-top: 2px solid transparent;
}
#topnav li:hover {
    border-top: 2px solid #0C3;
    color: #0C3;
}
#topnav a li {
    color: #FFF;
    line-height: 1.3em;
    text-decoration: underline;
}

Answer №1

The issue may be caused by the default margins on ul.nav_list overlapping with its parent elements (including body). By resetting those margins to zero, the problem should be resolved.

Answer №2

When examining the console, it appears that the style sheet is causing a spacing issue.

ul, menu, dir {
    display: block;
    list-style-type: disc;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    -webkit-padding-start: 40px;
}

You can view the screenshot below: https://i.sstatic.net/VaTVy.png

To fix this problem, overwrite the margin in the '.nav_list' CSS class

Here's an example:

.nav_list {
    text-decoration: none;
    background: #333;
    color: #FFF;
    list-style: none;
    position: relative;
    z-index: 1;
    -webkit-margin-before: 0px;
    -webkit-margin-after: 0px;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
 }

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 we enhance the appearance of a row of text by adding a background to the first letter?

Take a look at the image attached below: I quickly created this in Photoshop for corporate identity on documents. Now, I need to replicate it for an email signature. However, I'm not sure how to create a square/rectangular background for the first le ...

Center align a row with the help of Bootstrap 4.0

Here is some code with Bootstrap 4 classes that I am working with: <div class="container"> <div class="row"> <div class="col-xl-4 col-md-6 col-lg-4"> <div class="footer_widget"> <h3 class ...

Enhance the appearance of 6 image URLs by wrapping them in dynamic divs with the

Can someone assist me in displaying 6 images retrieved from a MySQL database on an MVC Razor view? Images 1 and 6 should be placed in separate divs labeled "item", while images 2, 3, 4, and 5 should be grouped together in a div called "item-small". Below i ...

Issues with Twitter Bootstrap Rendering in Internet Explorer

Encountering significant challenges in making a Twitter Bootstrap site compatible with Internet Explorer. Visit for the site in question. Below are screenshots from Chrome and Internet Explorer along with the corresponding HTML code. The issue is with the ...

Automatically Dismissing a Bootstrap Alert After a Set Number of Seconds

Having some trouble closing a Bootstrap alert automatically on my new site built using the Bootstrap Framework. The issue arises when trying to close the alert after a certain amount of time. On the main page of the site, there is a modal login form. When ...

Creating an efficient login system for my website - where do I start?

I've recently started diving into the world of web development, starting with HTML, CSS, and a bit of JavaScript. However, I've hit a roadblock - while I can perform basic styling, I'm struggling to make my projects interactive. My main que ...

The image spills out of its confines

Looking to create a dialogue box that fills the entire width and height of the screen? Want to divide its content into two sections - an image and a footer area with 2 rows of height? Struggling to contain the image within its designated space without over ...

Shifting an html element from side to side using javascript click event

I am new to utilizing JavaScript in conjunction with HTML elements, and I am seeking assistance in crafting a function for such interaction. The goal is to have an image that will shift either left or right based on its previous movement. For instance, up ...

Should I include container-fluid in the body or main level for a Bootstrap 4 website?

When designing a Bootstrap 4 site, is it better to add container-fluid at the body or main level? For example: <html> <head></head> <body class= "container-fluid"> <header></header> <main></main> <footer ...

Is using transform scale in CSS to scale SVG sprites a valid method of scaling?

I have been using an SVG sprite as a CSS background image in this manner: .icon-arrow-down-dims { background: url("../sprite/css-svg-sprite.svg") no-repeat; background-position: 16.666666666666668% 0; width: 32px; height: 32px; display: inline-b ...

Select a hyperlink to access the corresponding tab

I've been playing around with bootstrap and AngularJS. I placed nav-tabs inside a modal-window and have it open when clicking on a link. However, I want the appropriate tab to open directly upon click. For example, if I click on "travel", I want the t ...

What is the reason AJAX does not prevent page from refreshing?

Can anyone offer some guidance on using AJAX in Django? I'm attempting to create a basic form with two inputs and send the data to my Python backend without refreshing the page. Below is the AJAX code I am using: <script type="text/javascript& ...

Finding the XPath for a modal using Selenium

I must locate and select this input field... (name="BtnNext" value="İLERİ" class="NavigationButtonNextLightBox ") ...using XPath after a modal popup. I am unable to use .FindByClass because there are identical classes on the main page, but I specifical ...

Button displayed on complete Bootstrap 4.5 Card

When running the code below, the text "Click Me" appears when the mouse hovers over it. I actually want "Click Me" to be displayed for the entire card (list). <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel= ...

Instructions for removing and recreating an input field along with its parent elements when the value of a Select tag is changed

I currently have a table with four fields, as illustrated below: Semester | Exam Status | GPA | Fee Status My query is regarding the behavior when changing the value in Exam_Status: I noticed that the Select tag-> does not clear automatically. Specifi ...

Generating a highchart visualizing a pie chart using data from a local JSON file (OBJECT)

This is the JSON data from my JSON file {"diskspace":100,"diskspace.free":50,"time":8,"time.played":2,"controllers":25,"controllers.used":3, "controllers.new":10, "controllers.broken":12} I want to represent this JSON data in various forms of pie cha ...

How to refresh an array in Angular 4 after inserting a new element using splice method?

I have a Angular list displayed in a table, and I need to insert an element at a specific position. I have tried using the following code: array.splice(index, 0, element); While everything seems fine in the console with the element being added at the corr ...

Using the justify-content:space-between property does not seem to be effective in a Nextjs

In my Next.js app, I am facing an issue with the justify-content: space-between; property not working as expected for two divs inside a container. However, justify-content: center; works fine. Interestingly, when I use the same code in an index.html file, ...

Finding the appropriate method to access a template variable reference in a designated row of an Angular Material table (Angular 7)

Currently, I am working on implementing a more intricate version of a behavior inspired by Angular Material's tutorials. In my simplified example, an Angular Material table is populated with data from a string array. The first column contains input fi ...

Acquire information from a website utilizing an ajax function with VBA in Excel

I'm looking to scrape information from and transfer it into an Excel sheet. The challenge I'm facing is that the webpage utilizes an ajax function and does not have individual elements for each entry. Here's a snippet of the HTML code in qu ...