|
See notes and examples.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled document</title>
<style type="text/css">
body{
BACKGROUND: #dfd;
MARGIN: 0px;
PADDING: 0px;
}
div#1 {
background:red;
text-align:center;
}
</style>
</head>
<body>
<!--<body leftmargin="0" topmargin="0" rightmargin="0" bottommargin="0">
This sentence is equivalent to margin:0px in CSS; it can also be written like this in CSS:
body{
BACKGROUND: #dfd;
margin-left:0px;
margin-right:0px;
margin-right:0px;
margin-bottom:0px;
PADDING: 0px;
}
In fact, he refers to the four margins between the top, bottom, left, and right of the webpage body content from the browser window. The above three writing methods have the same effect.
padding: is the upper, lower, left, and right margins of the current element from its parent element, where the effect and margin should be the same. Look at the example below.
-->
<div id="1">
abcd
</div>
<br>Padding example
<table width="600" border="0" cellpadding="0" cellspacing="1" bgcolor="#FF0000">
<tr>
<td width="305" bgcolor="#FFFFFF" style="padding-left:50px;">A margin of 50 pixels from the left of this cell to start writing content</td>
<td width="295" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF" style="padding-left:10px;">1 pixel margin from the left of this cell to start writing content</td>
<td bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td bgcolor="#FFFFFF" style="padding:50px;">If the specific direction is not set, the up, down, left, and right are the same, both are 50 pixels. Here you can understand this text as body, and the upper, lower, left, and right margins of the cell as the four boundaries of the browser window. </td>
<td bgcolor="#FFFFFF"> </td>
</tr>
</table>
</body>
</html>
Another: your background:red; means to set the back color of the div, but if you use <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ /www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> your background: red; will be invalid, it is recommended to use background-color: red;, it should be a different standard. Try it yourself to find out. |
|