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

Searching for various values in PHP with user input

I am currently working on implementing a basic search tool that allows users to search the database by providing certain inputs. The form consists of 3 input fields: However, when I attempt to search one by one, only the first field functions correctly w ...

Attributes in HTML for EditorFor() within ASP.NET MVC

Is there a way to include HTML attributes in EditorFor()? For example: <%= Html.EditorFor(model => model.Control.PeriodType, new { disabled = "disabled", readonly = "readonly" }) %> I prefer not to rely on metadata for this. Update: I fou ...

toggle switch for numerical input

Whenever the "Qty" radio button is selected, I need to activate an input box that accepts numbers. Conversely, when the "rate" radio button is clicked, I want to disable this input box. This is how I designed it: <input type="radio" class="radioBtn" ...

Navigational tabs have been implemented in multiple independent sets, eliminating the need for multiple scripts to manage hiding content on click events

In a previous inquiry, I sought guidance on achieving a specific tab functionality like the one depicted below: https://i.stack.imgur.com/s2Gm8.png The query led to an insightful suggestion from @BradleyCoupland, who provided the following code snippet: ...

What is the best way to use createElement in JavaScript to insert <p> and <span> elements within a <div>?

I am currently experimenting with generating sentences accompanied by draggable text boxes. To achieve this, I intend to construct the following HTML structure using JavaScript exclusively: <div> <p>Data1<span class = "smallBox droppabl ...

Learning how to utilize various types of buttons in C# and ASP.NET with this

I was following this tutorial: I like everything the same except I want to make the following change: <section> <a rel="external" href="#button" id="button">&#xF011;</a> <span></span> </section> ...

Bootstrap 4's container overflowing feature

I am trying to create a container with both horizontal and vertical overflow using the "auto" value. I want the content inside this container, which will mainly consist of large tables, to be scrollable within a window. It would be ideal if this container ...

Utilize CSS to position an image in four various locations on a web page

Expressing this may be a challenge, but I'll give it a shot. Within a div, there is text that can vary in length based on user input. My goal is to have the ability to insert an image in one of several positions, determined by the selection made in a ...

Learn to Generate a Mathematical Quiz with Javascript

For a school project, I am tasked with developing a Math Quiz which showcases questions one at a time. The questions vary in type, including Multiple Choice, Narrative Response, Image Selection, Fill in the blank, and more. I require assistance in creatin ...

Hover image displacement

Can anyone help me identify the feature used in this price list where the mouseover changes and a big image appears underneath? I'm trying to achieve something similar but can't figure out how. Any guidance would be appreciated. ...

Image control failing to display SVG file

I am facing an issue with displaying an SVG file on the img control in angular10. When I try to use SVG, it's not showing up but it works fine when I change the file type to jpg for the same control. The img control is placed inside a nav bar. Here i ...

What is the best way to keep an HTML element visible on the page while it remains within the boundaries of another HTML object?

On my webpage, I have a selection of reports available. Currently, there are 4 sizable buttons located on the right-hand side for viewing, adding, editing, or deleting a report. However, there have been complaints from users who find it inconvenient to scr ...

Deleting various classes (jQuery)

Is there a more effective alternative to rewriting the following code snippet? $('element').removeClass('class1').removeClass('class2'); I am unable to utilize removeClass(); because it would eliminate ALL classes, and that ...

Generate HTML tags dynamically within a JSON document using PHP

Is there a way to incorporate HTML markups (generated dynamically by a CMS) into a JSON file? I am aware that in the html string, one must escape double quotes by adding "" as shown below. { "title": "Title", "da ...

Generate a dynamic text-box and drop-down list using HTML and JavaScript

My current project involves generating dynamic text-boxes based on the selection from a drop-down list and input field. When a user chooses 'Option 1' from the drop-down list and enters input such as 'grass', 'table', etc., t ...

When an input field is added to an HTML form, all elements positioned below it automatically inherit its attributes

I have a unique combination of HTML and CSS code that creates an impressive login form: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>Prepare to be amazed...</title> <l ...

What is causing onbeforeunload to consistently display a dialog box?

I'm facing an issue where my javascript code displays a confirmation dialog even when there is no unsaved data. I have simplified the problem to this bare minimum: window.addEventListener("beforeunload", (e) => { e.returnValue = null; retu ...

I would like to embed the HTML page within the specified div element

When attempting to load a HTML page inside the div, I encountered the following issue: <a href="#1" title="" class="base-banner" page="www.google.com for example"> <img src="images" alt=""></a> <div id="landingpage"> </div> ...

Formulate a jQuery array consisting of droppable components

I have successfully implemented draggable li-elements and droppable boxes using jQuery UI. Here is my structure: A list of 3 different permission types <ul> <li data-action="create">Create</li> <li data-action="edit">Edi ...

Looking for assistance with extracting only numerical values from a webpage using Selenium in Python

Website Elements <td style="font-size:20px;font-family:LucidaGrande,tahoma,verdana,arial,sans-serif;padding:10px;background-color:#f2f2f2;border-left:1px solid #ccc;border-right:1px solid #ccc;border-top:1px solid #ccc;border-bottom:1px solid #ccc; ...