Jack Westen Jack Westen - 3 months ago 6x
HTML Question

padding is not disappearing in html

enter image description here

This example is based on the w3schools.

I want to attach the "nav" part to the header. The red notification part is issue. I don't know why the "nav" is not attached to header. I applied the padding as 0 px. Who knows how to solve the problem? or am I misunderstanding padding? Thank you for the answer.

My html source is below.

<!DOCTYPE html>
div.container {
width: 100%;
border: 1px solid gray;

header, footer {
padding: 1em;
color: white;
background-color: black;
clear: left;
text-align: center;

nav {
float: left;
max-width: 160px;
margin: 0;
padding: 0em;

nav ul {
list-style-type: none;
padding: 0;

nav ul li {
padding : 25px;
border : 1px solid gray;

nav ul a {
text-decoration: none;

article {
margin-left: 170px;
border-left: 1px solid gray;
padding: 0px;
overflow: hidden;

<div class="container">
<h1>City Gallery</h1>

<li><a href="#">London</a></li>
<li><a href="#">Paris</a></li>
<li><a href="#">Tokyo</a></li>

<p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
<p>Standing on the River Thames, London has beeon a major settlement for two millennia, it's history going back to its founding by the Romans, who named it Londinium.</p>

<footer>Copyright ? W3Schools.com</footer>



your nav is built using ul tag, which has margin property set by default

this should solve your problem:

nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;

also, keep in mind that 0 shouldn't be used with units (it's a good practice)