margin: ***; padding: ***;
Browser |
|
---|
The margin property sets the margin around an element, and the padding property sets the padding of an element.
When you apply these properties to the UL or OL element, the spacing around the list can be adjusted.
ul {
margin: 0 0 0 20px;
padding: 0;
}
Property | Value | Explanation |
---|---|---|
margin | length, %, or auto | the top, bottom, left, and right margins |
padding | length, %, or auto | the top, bottom, left, and right paddings |
Screen shots of examples
The base code
div { border: 2px red solid; }
ul { border: 1px blue solid; }
li { border: 1px lightgreen solid; }
<div>
<ul>
<li>First list item</li>
<li>Second list item</li>
<li>Third list item</li>
</ul>
</div>
- The red border : The parent box. (DIV)
- The blue border : The whole of the list. (UL)
- The green border : The list item. (LI)
Code | MSIE | Firefox | Opera |
---|---|---|---|
The default | |||
ul {
|
|||
ul {
|
|||
ul {
|
|||
ul {
|