欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!

一、HTML 块元素

  • 大多数 HTML 元素被定义为块级元素或内联元素;
  • 元素在浏览器显示时,通常会以新行来开始和结束;
  • 如:<h1>,<p>,<ul>,<table>,<div>等标签;

二、HTML 内联元素

  • 内联元素在显示时通常不会以新行开始;
  • 如:<b>, <td>, <a>, <img>,<span>等标签;

三、HTML <div> 元素

  • HTML 中的<div> 元素是块级元素,它是可用于组合其他 HTML 元素的容器;
  • <div> 标签定义 HTML 文档中的一个分隔区块或者一个区域部分;
  • <div> 元素经常与 CSS 一起使用,用来布局网页;

四、div的使用

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<style>
 .all{
 width:500px;
 height:500px;
 margin:0 auto;
 background-color:#000;
 }
 .one{
 height:100px;
 background-color:#89E1BF;
 }
 .two{
 height:100px;
 background-color:#DEE099;
 }
 .three{
 height:100px;
 background-color:#D7A1CE;
 }
 
</style>
<body>
 <!--父div,all是黑色-->
 <div class="all">
 <!--子div,one是绿色-->
 <div class="one">
 </div>
 <!--子divtwo,是黄色-->
 <div class="two">
 </div>
 <!--子div,three是紫色-->
 <div class="three">
 </div>
 </div>
</body>
</html>

演示效果如图所示:

HTML基础知识之DIV

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/css-jiaocheng/tc58334.shtml