HTML layout

On the Internet, you can see formatted columns like newspapers everywhere.

Most websites can use the <div> or <table> elements to create multiple columns. CSS is used to position elements or create backgrounds and colorful looks for pages.

Use <div> elements to layout

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>
 
<div id="container" style="width:500px">
 
<div id="header" style="background-color:#00FFFF;">
<h1 style="margin-bottom:0;">标题</h1></div>
 
<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>菜单</b><br>
HTML<br>
CSS<br>
</div>
 
<div id="content" style="background-color:#00FF00;height:200px;width:400px;float:left;">
内容</div>
 
<div id="footer" style="background-color:#FF00FF;clear:both;text-align:center;">
版权 © php.cn</div>
 
</div>
 
</body>
</html>

Use tables for layout

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>
 
<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1>标题</h1>
</td>
</tr>
 
<tr>
<td style="background-color:#FFD700;width:100px;">
<b>菜单</b><br>
HTML<br>
CSS<br>
</td>
<td style="background-color:#eeeeee;height:200px;width:400px;">
内容</td>
</tr>
 
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
版权 © php.cn</td>
</tr>
</table>
 
</body>
</html>

HTML Layout - Helpful Tips

Tip: The biggest advantage of using CSS is that if the CSS code is stored in an external style sheet, the site will be easier to maintain. By editing a single file, you can change the layout of all pages. To learn more about CSS, visit our CSS tutorials.

#Tip: Since creating advanced layouts is time-consuming, using templates is a quick option. There are many free website templates available through search engines (you can use these pre-built website layouts and optimize them).


Continuing Learning
||
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
#Container{
width:1000px;
margin:0 auto;/**/
background:#CF3;
}
#Header{
height:80px;
background:#093;
}
#logo{
padding-left:50px;
padding-top:20px;
padding-bottom:50px;
}
#Content{
height:600px;
/*使overflow:auto
     ;1
     footermargin-top:*/
margin-top:20px;/*margincontentheader*/
background:#0FF;
}
#Content-Left{
height:400px;
width:200px;
margin:20px;/*20*/
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
submitReset Code
图片放大关闭