First, the site layout
1, the site can be arranged in a number of columns (like a magazine or newspaper).
2, the site layout can use <div> and <table> elements to create multiple columns.
3, CSS to locate elements, create background and color, and so on.
4, the HTML table is not the layout tool, mainly renders tabular data, is not recommended to use.
Second, HTML layout using <div> elements
1. Div Yuan is a block-level element used to group HTML elements.
2, the following is an example, using the CSS style sheet:
1 <!--HTML Div layout --
2 <! DOCTYPE html>
3
4
5 <!--definition css-->
6 <style type="Text/css">
7 Div#container{width:600px;}
8 Div#header{background-color:#ff0000;}
9 Div#menu{background-color:#ff0088; Height:200px; width : 200px; float : left;}
10 Div #content { background-color : #ff8888 ; Height : 200px ; width :400px ; Float : left }
One div#footer{background-color:#88ff88; Clear:both; text-align:center;}
H1{margin-bottom:0;}
H2{margin-bottom:0; Font-size:16px}
ul{margin:0;}
All li{list-style:none;}
</style>
<!--body part --
<body>
<divid="container">
<divid="header">
Page title
</div>
24
<divid="menu">
nav bar
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</div>
33
<divid="Content"> page content in this input </div>
<divid="Footer"> All rights reserved </div>
</div>
Panax Notoginseng </body>
38
The preview works as follows:
Third, HTML layout using <table> elements
Using HTML <table> tags is an easy way to create layouts as follows:
1 <! DOCTYPE html>
2
3 <body>
4
5 <tablewidth="500px " border="0">
6 <tr>
7 <tdcolspan="2" style="Background-color: #99bbbb;" >
8 Title
9 </td>
Ten </tr>
11
<trvalign="Top">
<tdstyle="Background-color: #ffff99; width:100px;text-align:top;" >
<b>Menu</b><br/>
HTML<br/>
CSS<br/>
+ JavaScript
</td>
19
<tdstyle="Background-color: #EEEEEE; height:200px;width:400px;text-align:top;" > Content</td>
</tr>
22
<tr>
<tdcolspan="2" style="Background-color: #99bbbb; text-align:center;" > Copyright</td>
</tr>
</table>
27
</body>
Show the effect:
Hint: Through CSS, make the site easier to maintain, change a file can change the layout of all pages. Creating an advanced layout is difficult and can be created using templates.