Copy: How to add margins to items
P粉037215587
2023-08-02 22:33:27
<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>
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;