Bardelman
Bardelman

Reputation: 2298

Why CSS padding is inherited from ul to il

In a code example an ul's padding was set to 0

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

and all the ul items and sub-items had their padding set to 0 too as it was inherited from the ul and that was strange for me because the padding property doesn't have inheritance so why this happens ?

enter image description here

Upvotes: 0

Views: 178

Answers (1)

Oriol
Oriol

Reputation: 288260

It doesn't happen. Blame Chrome's devtools.

ul {
  border: 1px solid blue;
  padding-left: 100px;
}
li {
  border: 1px solid red;
  /* Does not inherit padding */
}
<ul>
  <li>Foo</li>
  <li>Bar</li>
</ul>

Upvotes: 1

Related Questions