How does the margin works in the below code? in the given code I have consider the top margin for the border
as 300px and 200px top margin for the ul
. So when I inspect in the browser the top-margin for the body
highlighted from the top of the webpage, and when I inspect the top margin for the ul
it is not highlighted from the top of the page. the below is the given code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
<TITLE>Examples of margins, padding, and borders</TITLE>
<STYLE type="text/css">
/* as you can see I have given the top margin as 300px*/
body
{
margin : 300px 0px 0px 0px ;
}
/* as you can see I have given the top margin as 200px for ul*/
UL
{
background: yellow;
margin: 200px 12px 12px 12px;
padding: 2px; /* No borders set */
}
LI
{
color: white; /* text color is white */
background: blue; /* Content, padding will be blue */
margin: 12px 12px 12px 12px;
padding: 12px 0px 12px 12px; /* Note 0px padding right */
list-style: none /* no glyphs before a list item */
/* No borders set */
}
LI.withborder
{
border-style: dashed;
border-width: medium; /* sets border width on all sides */
border-color: lime;
}
</STYLE>
</HEAD>
<BODY>
<UL>
<LI>First element of list
<LI class="withborder">Second element of list is
a bit longer to illustrate wrapping.
</UL>
<UL>
<LI>First element of list
<LI class="withborder">Second element of list is
a bit longer to illustrate wrapping.
</UL>
</BODY>
</HTML>