<!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">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>块与内联</title>


<style type="text/css">

body,div,a,span{

margin:0;

padding:0;

}

#content{

background:#CCFFFF;

width:300px;

height:300px;

}

#content_1{

background:#ccc;

width:100px;

height:100px;

display:inline;<!--让块元素div变成内联,宽度和高度不起作用了-->

}

#content_2{

background:pink;

width:100px;

height:100px;

display:inline;<!--让块元素div变成内联,宽度和高度不起作用了-->

}

span{

display:block;<!--将内联元素span变成块状,即让a独占一行-->

}

</style>


</head>


<body>


<div id="content">

<div id="content_1">

小盒子1

</div>

<div id="content_2">

小盒子2

</div>

<a href="http://www.baidu.com" target="_blank">百度</a>

</div>

<span>独占一行</span>

<a href="http://www.hao123.com" target="_blank">hao123</a>

</body>

</html>