当前位置: 首页 > 文档资料 > HTML 入门教程 >

<div>

优质
小牛编辑
123浏览
2023-12-01

描述 (Description)

HTML

标记用于定义文档的一部分。 使用div标记,您可以将大部分HTML元素组合在一起,并使用CSS格式化它们。

div标签和span标签之间的区别在于div标签与块级元素一起使用,而span标签与内联元素一起使用。

例子 (Example)

<!DOCTYPE html>
<html>
   <head>
      <title>HTML div Tag</title>
      <link rel = "stylesheet" href = "style2.css">
   </head>
   <body>
      <div id = "contentinfo">
         <p>Welcome to our website. We provide tutorials on various subjects.</p>
      </div>
   </body>
</html>

这是csss文件style2.css

#contentinfo p { 
   line-height: 20px;
   margin: 30px;
   padding-bottom: 20px; 
   text-align: justify;
   width: 140px;
   color: red; 
}

全局属性 (Global Attributes)

此标记支持HTML Attribute Reference描述的所有全局属性

具体属性 (Specific Attributes)

HTML

标记还支持以下附加属性 -
属性描述
自动对焦 HTML-5autofocusSpecifies

事件属性 (Event Attributes)

此标记支持HTML Events Reference中描述的所有事件属性

浏览器支持 (Browser Support)

ChromeFirefoxIEOperaSafariAndroid
YesYesYesYesYesYes