本文翻译自:What is the difference between and

?

What is the difference between <section> and <div> in HTML? HTML中的<section><div>什么区别? Aren't we defining sections in both cases? 我们不是在两种情况下定义部分吗?

#1楼

参考:

#2楼

Just an observation - haven't found any documentation corroborating this 只是一个观察 - 没有找到任何证实这一点的文件

If a section contains another section, a h1-header in the inner section is displayed in a smaller font than a h1- header in outer section. 如果某个部分包含另一个部分,则内部部分中的h1标题将以比外部部分中的h1-标题更小的字体显示。 When using div instead of section the inner div h1-header is diplayed as h1. 当使用div而不是section时,内部div h1-header被显示为h1。

<section><h1>Level1</h1>some text<section><h1>Level2</h1>some more text</section>
</section>

-- the Level2 - header is displayed in a smaller font than the Level1 - header. - Level2 - 标题以比Level1 - 标题更小的字体显示。

When using css to color h1 header, the inner h1 were also colored (behaves as regular h1). 当使用css为h1标题着色时,内部h1也被着色(表现为常规h1)。 It's the same behaviour in Firefox 18, IE 10 and Chrome 28. 这与Firefox 18,IE 10和Chrome 28中的行为相同。

#3楼

<div> Vs <Section>

Round 1 第1轮

<div>: The element (or HTML Document Division Element) is the generic container for flow content, which does not inherently represent anything. <div>: 元素(或HTML文档分割元素)是流内容的通用容器,它本身并不代表任何内容。 It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang. 它可用于将元素分组以用于样式目的(使用class或id属性),或者因为它们共享属性值,例如lang。 It should be used only when no other semantic element (such as <article> or <nav> ) is appropriate. 只有在没有其他语义元素(例如<article><nav> )合适时才应该使用它。

<section>: The Section element ( <section> ) represents a generic section of a document, ie, a thematic grouping of content, typically with a heading. <section>: Section元素( <section> )表示文档的通用部分,即内容的主题分组,通常带有标题。

Round 2 第2轮

<div>: Browser Support <div>: 浏览器支持

<section>: Browser Support <section>: 浏览器支持

The numbers in the table specifies the first browser version that fully supports the element. 表中的数字指定了完全支持该元素的第一个浏览器版本。

In that vein, a div is relevant only from a pure CSS or DOM perspective, whereas a section is relevant also for semantics and, in a near future, for indexing by search engines. 在这种情况下,div仅与纯CSS或DOM视角相关,而section也与语义相关,并且在不久的将来也与搜索引擎进行索引相关。

#4楼

The <section> tag defines sections in a document, such as chapters, headers, footers, or any other sections of the document. <section>标记定义文档中的部分,例如章节,页眉,页脚或文档的任何其他部分。

whereas: 然而:

The <div> tag defines a division or a section in an HTML document. <div>标签定义HTML文档中的分区或部分。

The <div> tag is used to group block-elements to format them with CSS. <div>标签用于对块元素进行分组,以使用CSS对其进行格式化。

#5楼

In the HTML5 standard, the <section> element is defined as a block of related elements. 在HTML5标准中, <section>元素被定义为相关元素的块。

The <div> element is defined as a block of children elements. <div>元素被定义为子元素块。

#6楼

Take caution not to overuse the section tag as a replacement for a div element. 请注意不要过度使用section标记作为div元素的替代。 A section tag should define a significant region within the context of the body . section标签应该定义正文上下文中的重要区域。 Semantically, HTML5 encourages us to define our document as follows: 从语义上讲,HTML5鼓励我们按如下方式定义文档:

 <html> <head></head> <body> <header></header> <section> <h1></h1> <div> <span></span> </div> <div></div> </section> <footer></footer> </body> </html> 

This strategy allows web robots and automated screen readers to better understand the flow of your content. 此策略允许Web机器人和自动屏幕阅读器更好地了解您的内容流。 This markup clearly defines where your major page content is contained. 此标记明确定义了主要页面内容的包含位置。 Of course, headers and footers are often common across hundreds if not thousands of pages within a website. 当然,页眉和页脚通常在网站中的数百个页面(而不是数千个页面)中是通用的。 The section tag should be limited to explain where the unique content is contained. 应限制section标记以解释包含唯一内容的位置。 Within the section tag, we should then continue to markup and control the content with HTML tags which are lower in the hierarchy, like h1 , div , span , etc. section标签中,我们应该继续使用层次结构中较低的HTML标记来标记和控制内容,例如h1divspan等。

In most simple pages, there should only be a single section tag, not multiple ones. 在大多数简单页面中,应该只有一个节标记,而不是多个标记。 Please also consider also that there are other interesting HTML5 tags which are similar to section . 另请注意,还有其他有趣的HTML5标签与部分类似。 Consider using article , summary , aside and others within your document flow. 考虑在文档流程中使用文章 , 摘要旁边和其他内容。 As you can see, these tags further enhance our ability to define the major regions of the HTML document. 如您所见,这些标记进一步增强了我们定义HTML文档主要区域的能力。

section和div有什么区别?相关推荐

  1. html5中还有div吗,关于html5中的section标签与div标签的区别(内有实例)

    摘要 腾兴网为您分享:关于html5中的section标签与div标签的区别(内有实例),周公解梦,智学网,学习计时,完美root等软件知识,以及网上预约医院软件,字体预览软件,铁血联盟卷土重来,海量 ...

  2. 关于html5中section标签与div标签的区别

    关于html5中section标签与div标签的区别 本篇文章主要的想大家介绍了关于HTML5 section标签和div标签的区别,section和div的用法看似相近,实则差的也不是太多,有些地方 ...

  3. html5 section与div,关于html5中的section标签与div标签的区别(内有实例)

    本篇文章主要的想大家介绍了关于HTML5 section标签和div标签的区别,section和div的用法看似相近,实则差的也不是太多,有些地方可以相互转换都行,但有些地方只能用section或者只 ...

  4. div与span区别及用法

    以下是在没有对开发网页页面设置css样式时候情况下,系统默认情况下的介绍 div与span区别 div占用的位置是一行, span占用的是内容有多宽就占用多宽的空间距离,说明如下图 分析:从上图很容易 ...

  5. 浅谈table布局和div布局的区别

    目录 背景 table布局 div+css布局 总结: table布局和div布局的区别 背景 早期的网页布局,基本都是采用table布局的.早期的网页相对来说比较的简单,类似于报纸一样,只有文字和静 ...

  6. section与div

    section和div 一.DIV div即division(区块),把文档分割为独立的.不同的部份.作用,以下三种情况应该用div标签: 1.用于页面布局,且不是 header.footer 之类的 ...

  7. 简述div标签和span标签的不同_SPAN标签和DIV标签的区别

    SPAN元素和DIV元素有什么区别 解决思路: 最明显的区别是:DIV是块元素,SPAN是内嵌元素.块元素相当于内嵌元素在前后各加一个 换行.其实,块元素和行内元素也不是一成不变的,只要给块元素定义d ...

  8. Section与Segment间的区别

    Section与Segment间的区别 汇编语法关键字 程序的加载 链接过程 示例 总结 汇编语法关键字 在汇编源码中,通常用语法关键字section或segment来表示一段区域,它们是编译器提供的 ...

  9. html和div有什么区别,div与css区别是什么?

    div与css区别 常常看见大家以div css命名 HTML网页重构,那么作为新手新接触DIV CSS布局来说,div和css什么区别? 一.性质的区别 div是html标签,CSS是代表样式表. ...

最新文章

  1. 模拟频率和数字频率的区别
  2. python socket select 错误 Filedescriptor out of range in select 解决方法
  3. 鸿蒙适配倒计时,倒计时2天!首批鸿蒙OS适配名单确定,你的手机在列吗?
  4. 《JS权威指南学习总结--3.8类型转换》
  5. C#读写txt文件的两种方法介绍[转]
  6. javascript 克隆/clone:Object.assign
  7. android模糊检索_【android学习笔记】ormlite学习之模糊搜索like
  8. vuex 的 action 传参问题
  9. Oracle10g安装了11g的ODAC后,PL/SQL连接提示TNS:无法解析指定的连接标识符
  10. 推荐一款专业串烧歌曲的音乐合并软件
  11. iOS 播放系统提示音和震动
  12. RadioButton 只读
  13. 读书笔记-《人人都是产品经理V1.1》
  14. Python批量改变图片名字
  15. 常见点击反应(Click Reactions)及其试剂——CuAAC
  16. selenium click点击无反应问题解析
  17. java中有几种方法可以实现一个线程?用什么关键字修饰同步方法? stop()和suspend()方法为何不推荐使用?
  18. JS中使用bignumber处理高精度小数 失去去精确度运算 bigNumber用法
  19. 送一个大马给有需要的人,请不要做非法之事
  20. 详细设计 英文_谷歌英文网站如何优化?

热门文章

  1. 一个老程序员的心里话---想创业的技术人员可以看
  2. Devexpress VCL Build v2014 vol 14.2.6 发布
  3. 从Exchange 通往Office 365系列(五)部署MailBox服务器
  4. 判断数据表是否存在,不存在则创建
  5. Database2Sharp重要更新之生成Winform框架界面代码
  6. 查找命令find和其他常用查找命令
  7. 为什么哈希表的容量一定要是 2的整数次幂?
  8. ajax同步导致ajax上面的代码不执行?
  9. HttpWebRequest的timeout和ReadWriteTimeout
  10. CenOS6 nginx+pxe+tftpd+samba/nfs+dhcpd 无盘安装windows  linux