How to remove whitespace from a div/container

black_yurizan

I have a navigation menu link that has extra whitespace at the bottom of the div tag with the id of nav. It is not because margin or padding, but there is some sort of whitespace that is not allowing the ul tag to touch the bottom of the div with the id of nav. How do I get it to do so. Here is the link

* {
  padding: 0;
  margin: 0;
}
#nav {
  border: 1px solid black;
  text-align: center;
  min-width: 300px;
}
#nav ul {
  padding: 10px 0;
  display: inline-block;
}
#nav li {
  float: left;
  list-style: none;
  margin-left: 50px;
}
#nav a {
  text-decoration: none;
  color: black;
  padding: 15px 10px;
}
#nav a:hover {
  color: white;
  background: black;
}
<div id="nav">
  <ul>
    <li><a href="#">link</a>
    </li>
    <li><a href="#">link</a>
    </li>
    <li><a href="#">link</a>
    </li>
    <li><a href="#">link</a>
    </li>
  </ul>
</div>

j08691

The gap is reserved space given to descender text elements (e.g. j, y, g). Remove it by adding vertical-align:top to your <ul>

* {
  padding: 0;
  margin: 0;
}
#nav {
  border: 1px solid black;
  text-align: center;
  min-width: 300px;
}
#nav ul {
  padding: 10px 0;
  display: inline-block;
  vertical-align: top;
}
#nav li {
  float: left;
  list-style: none;
  margin-left: 50px;
}
#nav a {
  text-decoration: none;
  color: black;
  padding: 15px 10px;
}
#nav a:hover {
  color: white;
  background: black;
}
<div id="nav">
  <ul>
    <li><a href="#">link</a>
    </li>
    <li><a href="#">link</a>
    </li>
    <li><a href="#">link</a>
    </li>
    <li><a href="#">link</a>
    </li>
  </ul>
</div>

Note that the list items poke out below the div because of the padding you applied to #nav a which can be adjusted.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to remove whitespace from explode

From Dev

how to remove whitespace from explode

From Dev

How to remove whitespace from string in Ruby

From Dev

How to remove whitespace from end of string in Python?

From Dev

How to remove extra whitespace from image in opencv?

From Dev

How to remove whitespace from an image in OpenCV?

From Dev

Python: How to remove whitespace from number in a string

From Dev

How to remove whitespace from specifc line?

From Dev

How to remove leading whitespace from a string in Bash

From Dev

How to remove whitespace from above text in a div

From Dev

Remove whitespace from QTextEdit

From Dev

Remove whitespace from SVG

From Dev

How To Remove Whitespace on Merge

From Dev

How to remove trailing whitespace changes from a sequence of git commits

From Dev

How to remove redundant spaces/whitespace from a string in Golang?

From Dev

How can I remove trailing whitespace from a hunk in Magit?

From Dev

How to remove Whitespce from stringArray formed based on whitespace

From Dev

How can I remove all whitespace from string?

From Dev

How to remove extra whitespace around body from Zurb Foundation

From Dev

Remove whitespace from matplotlib heatplot

From Java

Remove all whitespace from string

From Dev

Remove whitespace from part of a string

From Dev

Remove whitespace from matplotlib heatplot

From Dev

How to remove the whitespace below the text?

From Dev

How to remove whitespace in array element?

From Dev

Remove empty or whitespace strings from array - Javascript

From Dev

Remove Insignificant Whitespace From Xml Document

From Java

Efficient way to remove ALL whitespace from String?

From Dev

Postgresql - remove any whitespace from sub string

Related Related

HotTag

Archive