Having trouble tackling whitespace removal in the DIV? Usual methods seem ineffective?

I am currently working on a vertical-align "3 block" design and trying to eliminate the white space between the divs. I have experimented with setting the font-size of the body to 0px and then assigning individual font sizes to each child, but this approach is not proving to be effective. Another attempt involved commenting out after the closing div and before the opening div, but this also did not yield the desired results.

I have considered options like not closing tags (which HTML5 supports) or using negative margins, but both methods have drawbacks and are not ideal solutions for this issue. Is there a simpler and cleaner way to solve this problem?

Answer №1

I made a simple addition that took care of the margin issue:

p, div, ol {
  margin: 0px;
}

By adding this snippet of code, the margin disappeared as expected.

However, it's important to note that using a generic selector like * is not advised, so it would be advisable to use a more specific selector for better practice.

    html,
    body {
      height: 100%;
    }
    html {
      display: table;
      margin: auto;
    }
    p, div, ol {
      margin: 0px;
    }
    body {
      background-color: #BFBFBF;
      width: 1180px;
    }
    #header {
      background-color: #EEEEEE;
      width: 1180px;
      height: 165px;
    }
    #logo {} #logout {} #navigation {} ul {} ul li {} ul li:hover {} ol {} .todo {} .wip {} .done {} a {} a:visited {} #content {
      background-color: #EEEEEE;
    }
    #footer {
      background-color: #35363A;
      height: 76px;
    }
    ul {} li {} .copyright {} form {} #newslettercontent {} .table {
      font-size: 12px;
      color: #333333;
      border-width: 1px;
      border-color: #729ea5;
      border-collapse: collapse;
    }
    .table th {
      font-size: 12px;
      background-color: #acc8cc;
      border-width: 1px;
      padding: 8px;
      border-style: solid;
      border-color: #729ea5;
      text-align: left;
    }
    .table tr {
      background-color: #ffffff;
    }
    .table td {
      font-size: 12px;
      border-width: 1px;
      padding: 8px;
      border-style: solid;
      border-color: #729ea5;
    }
    .table tr:hover {
      background-color: #ffff99;
    }
<div id="header">
  <a href="index.php">
    <img id="logo" src="./images/logo.png" />
  </a>
  <div id="navigation">
    <ul>
      <a href="./index.php">
        <li>Home</li>
      </a>
      <a href="./newsletter.php">
        <li>Newsletter</li>
      </a>
      <a href="../users/list.php">
        <li>User List</li>
      </a>
      <a href="./admin/index.php">
        <li>Admin Panel</li>
      </a>
    </ul>
  </div>
</div>
<div id="content">
  <p>
    <br />
    <h2></h2>
    <br />
    <br />

    <ol>

    </ol>
  </p>
</div>
<div id="footer">
  <p class="copyright"></p>
</div>

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

What is the process for extracting data from a canvas tag and why does it appear invisible on my browser?

The highlighted area in this image contains the HTML content and the red circle marks the section to be scraped The phone number can be found within the canvas tag. However, when trying to scrape the tag, it shows "Your browser does not support the HTML5 c ...

fade in and out twice (for beginners)

Jquery <script> //Code snippet $(document).ready(function(){ $(".team").click(function(){ $(".panel").fadeToggle("3000"); }); $(".team").click(function(){ $(".teamh").fadeToggle("3000"); }); }); </script> HTM ...

Retrieving the HTML Head Element from Internet Explorer's Document Object Model

For extracting the HTML body of a document, I am familiar with utilizing the IHTMLDocument2 interface by invoking the get_body member function. However, obtaining the head seems to be more challenging. Is there an alternative method since the IHTMLDocumen ...

Adjust dimensions of an image retrieved from a URL

Is there a way to adjust the size of the image displayed here?: var picture = new Image(); picture.src = 'http://www.example.com/images/logo.png'; picture.width = 200; //trying to change the width of the image $('canvas').css({ ...

Can you employ a right-side offset in Bootstrap 4?

Is it possible to align a button with a textbox using the Bootstrap 4 layout system? https://i.sstatic.net/tN9II.png <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/> <div ...

The identical animation is experiencing delays in various directions

Having an issue with my image slider - when clicking on the previous image button, the animation takes longer compared to when clicking on the next image button, even though the animation duration is set to be the same for both. Any idea why this might be ...

What is the best way to incorporate HTML styling into a PHP email tutorial focused on Swift Mail?

I recently created a competition page for a client, and they have requested that the email sent to customers be more visually appealing than just plain text. The tutorial I followed only included basic text within the 'send body message' section. ...

Unlimited scrolling feature on a pre-filled div container

Looking for a way to implement infinite scroll on a div with a large amount of data but struggling to find the right solution? I've tried various jQuery scripts like JScroll, MetaFizzy Infinite Scroll, and more that I found through Google search. Whi ...

What is the most effective way to send an email in PHP with a table format

<?php $result = mysqli_query($con, "SELECT * FROM cse"); $mail_data = ""; while ($row = mysqli_fetch_array($result)) { $Hallticket_No = $row['Hallticket No']; $Name = $row['Name']; $Email_ID = $row[&apos ...

Change the Background of Your Body?

Here's the deal. I'm looking to create a cool effect where the background of the body slowly fades out and changes periodically in a loop using CSS and jQuery. Any suggestions on how I can make this happen? Appreciate your help! ...

"Interacting with the ng-keypress event causes the page to smoothly scroll

As a newcomer to angularjs, I am trying to figure out why my component (which simulates a "checkbox" using fontawesome icons) causes the page to scroll down when the user presses the space key. Here is a snippet of my component : ugoFmk.component(' ...

Why isn't it possible to send POST data to a JSON file using JQuery/AJAX?

I'm currently learning how to use JQuery/Ajax from a helpful tutorial on YouTube. To watch the video, simply click here. While I can successfully retrieve data from the order.json file, I encounter an error whenever trying to send POST requests. Bel ...

Different ways to modify the underline and label color in Material-UI's <Select/> component

A while ago, I came across this useful demo that helped me change the colors of input fields. Here is the link: https://stackblitz.com/edit/material-ui-custom-outline-color Now, I'm on a quest to find a similar demo for customizing the color of selec ...

The space residing above my primary container division

I recently finished creating a basic web app, but I'm encountering an issue with the smallest media query where there is an unwanted top gap. Despite trying multiple methods and researching solutions online, I have not been able to resolve this proble ...

Issue with calculating positions in the jquery.quicksand plugin

I've been playing around with a website for the past couple of days and I have successfully implemented the jquery.quicksand plugin to organize my portfolio entries. However, I've run into an issue when selecting the 'all' filter. If a ...

Sending HTML output to a PHP script

After setting up my HTML form with an action attribute pointing to "filename.php" and a method of post, I managed to generate JSON output by clicking the Submit button using the following code: $('#result').text(JSON.stringify($('form' ...

Refreshing your web project with the newest and stylish Bootstrap and SASS upgrades

I have been working on an ASP .NET web project that includes jQuery, jQuery UI, and reset/normalize css stylesheets. The CSS code is not up to par, so I plan to revamp it with a budget allocated for the task :) During my research, I found two intriguing s ...

Determining the height of a Bootstrap column in relation to another element

Utilizing the grid layout from bootstrap, I have the following structure: <div id="prof_cont_enclose"> <div class="row"> <div class="prof_cont_row"> <div class="col-xs-12 col-sm-4 col-md-2 col-lg-2 prof_elem"&g ...

Show the time with AM/PM without displaying the year, month, or day

Currently, I am struggling to show the time as AM when my website loads using the format mm-dd-yyyy --:-- AM in a datetime-local input. The value attribute of datetime-local is causing some confusion for me. ...

Is there a way to efficiently retrieve and handle multiple $_POST records in PHP simultaneously?

I am currently working on developing a management interface that allows administrators to make bulk edits to members of a website all at once. While we already have the capability for single edits, there is a need for an option to modify all users simultan ...