简介
HTML <div> 元素 (或 HTML 文档分区元素) 是一个通用型的流内容容器,它在语义上不代表任何特定类型的内容,它可以被用来对其它元素进行分组,一般用于样式化相关的需求(使用 class 或 id 特性) 或者对具有相同特性的一组元素进行分组 (比如 lang),它应该在没有任何其它语义元素可用是才使用 (比如 <article> 或 <nav>) 。
- Content categories Flow content, palpable content.
- Permitted content Flow content.
- Tag omission 不允许,开始标签和结束标签都不能省略。
- Permitted parent elements Any element that accepts flow content.
- DOM interface
HTMLDivElement
特性
该元素包含所有 全局特性.
在 HTML5 中, <div> 的 align 特性已经 .
示例
<div> <p>这里可以是任何内容,比如 <p>, <table>,一切由你作主。</p> </div>
结果
这里可以是任何内容,比如 <p>, <table>,一切由你作主。
Specifications
| Specification | Status | Comment |
|---|---|---|
| WHATWG HTML Living Standard <div> |
Living Standard | |
| HTML5 <div> |
Recommendation | |
| HTML 4.01 Specification <div> |
Recommendation |
浏览器兼容性
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Basic support | 1.0 | (Yes) | (Yes) | (Yes) | (Yes) |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
相关内容
- Semantic sectioning elements:
<section>,<article>,<nav>,<header>,<footer> <span>element for styling of phrasing content