本文翻译自: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. python 中文识别 不用tesseract_Python——验证码识别 Pillow + tesseract-ocr
  2. 42_ResNet (深度残差网络)---学习笔记
  3. python 不执行函数_解决python调用自己文件函数/执行函数找不到包问题
  4. 复旦研究生怒怼华为:2w 月薪是侮辱价!
  5. python中有那几种赋值_详解Python列表赋值复制深拷贝及5种浅拷贝
  6. django 1.8 官方文档翻译: 2-6-2 遗留的数据库
  7. 安装centos7步骤_Centos7下源码编译安装mysql5.7 详细步骤 小白也能安装
  8. 奇偶个数 中国大学生mooc 翁恺 C语言
  9. stm32F4的ADC+DMA+Timer,实现2MHz连续采样。1LSB分辨率,极低噪声。
  10. 广义表head tail 运算_双链表实现LRU缓存淘汰策略
  11. linux查看docker进程流量,linux中查看docker内存占用情况
  12. 计算机启动过程过程图,计算机启动过程图文详解(一)----计算机初始化启动过程...
  13. 制作ESXi6.5启动盘
  14. 五、Python复习教程(重点)-爬虫框架实战
  15. Android paint 效果研究
  16. 2.4G信道跳频-LFSR-C代码实现
  17. java画图抗锯齿_Android编程画图之抗锯齿解决方法
  18. 匿名函数的this指向
  19. 1074 Reversing Linked List
  20. WEEK5 周记 作业——差分数组_TT的魔法猫

热门文章

  1. 一个老程序员的心里话---想创业的技术人员可以看
  2. 仔仔手机安全卫士demo(四)
  3. C#十进制与十六进制转换
  4. codeforces 261D Maxim and Increasing Subsequence(树状数组优化最长上升子列)
  5. Asp.net 邮件传输
  6. 关于去掉linux打开文件数限制的办法
  7. ACM - ICPC World Finals 2013 A Self-Assembly
  8. startService与bindService
  9. 判断客户端是否安装FlashPlayer及版本
  10. 乱谈互联网产品开发(二)