Copy: How to add margins to items
P粉037215587
P粉037215587 2023-08-02 22:33:27
0
1
487
<p>I have an unordered list and I set the style to none, which creates the default indented space. <br /><br />My understanding of margins and padding is that margins are the outer space of an element, so I tried to use margin: 0 to fix the gap, but it didn't work. When I use padding: 0, it removes the indented space from the li items. <br /><br />Now I'm confused why there is padding and not margin in this case. </p><p><br /></p> <p><br /></p> <pre class="brush:css;toolbar:false;">ul { list-style-type: none; padding: 0px; }</pre> <pre class="brush:html;toolbar:false;"><ul> <li> Linkedin </li> </ul></pre> <p><br /></p>
P粉037215587
P粉037215587

reply all(1)
P粉511757848

The default setting of the browser is to add some padding to the UI instead of margin. So using padding: 0px will override the browser's default value.

Look at the Computed tab on the right, it shows a list of browser styles padding-left: 40px;


ul.no-padding {
  list-style-type: none;
  padding: 0px;
}

ul.no-margin {
  list-style-type: none;
  margin: 0px;
}
<ul>
  <li>
    Linkedin
  </li>
</ul>

<ul class="no-margin">
  <li>
    Linkedin
  </li>
</ul>

<ul class="no-padding">
  <li>
    Linkedin
  </li>
</ul>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template