


When I first came into contact with HTML5, I was very uncomfortable with its tags, and I even felt a little disgusted with it. Especially for the tags div, section, and article, I really don’t know when they should be used.
div
HTML Spec:
The div element has no special meaning at all.
This tag is the one we see and use the most. It has no semantics per se and is used as a hook for layout and styling or scripting.
section
HTML Spec: “The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.”
Contrary to the semantics of div, simply put, section is a div with semantics, but don’t think it’s really that simple. A section represents a topical piece of content, usually with a title. Seeing this, we may think that a blog post or a separate comment can just use section? Read next:
Authors are encouraged to use the article element instead of the section element when it would make sense to syndicate the contents of the elemen.
Article should be used instead of section when the content of the elements is aggregated to make more sense.
So, when should section be used? Read on:
Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A Web site's home page could be split into sections for an introduction, news items, and contact information.
Typical scenarios forsection application include chapters of articles, tabs in the tab dialog box, or numbered sections in the paper. The homepage of a website can be divided into sections such as introduction, news, and contact information. In fact, I am very interested in the information conveyed here, because I feel that section and artilce to be introduced below are more suitable for modular applications. This topic will be discussed in a special article in the future, so I will skip it here for now.
Be aware that the W3C also warns:
The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead. A general rule is that the section element is appropriate only if the element's contents would be listed explicitly in the document's outline."
section is more than just an ordinary container tag. When a tag is just for styling or to facilitate scripting, div should be used. Generally speaking, a section is appropriate when the element's content appears explicitly in the document outline.
- article>
- hgroup> h1>Applesh1> h2>Tasty, delicious fruit!h2> hgroup>
- p>The apple is the pomaceous fruit of the apple tree.p>
- section>
- h1>Red Delicioush1>
- p>These bright red apples are the most common found in many supermarkets.p>
- section>
- section>
- h1>Granny Smithh1>
- p>These juicy, green apples make a great filling for apple pies.p>
- section>
- article>
article
HTML Spec:
The article element represents a self-contained composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication.
article is a special section tag, which has clearer semantics than section. It represents an independent and complete block of related content. Generally, an article will have a title section (usually contained within the header) and sometimes a footer. Although a section is also a thematic piece of content, the article itself is independent and complete in terms of structure and content.
The HTML Spec then lists some applicable scenarios for article.
This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.
When article is embedded in article, in principle, the content of the inner article is related to the content of the outer article. For example, in a blog post, the article containing user-submitted comments should be hidden within the containing blog post article.
The question is what counts as “complete independent content”? One of the easiest ways to tell is to see if the content is complete in the RSS feed. Check whether the content is complete and independent without its context.
Example:
- article>
- header>
- h1>The Very First Rule of Lifeh1>
- p>time pubdate datetime="2009-10-09T14:28-08:00">time>p>
- header>
- p>If there's a microphone anywhere near you, assume it's hot and sending whatever you're saying to the world. Seriously.p>
- p>...p>
- footer>
- a href="?comments=1">Show comments...a>
- footer>
- article>
- article>
- header>
- h1>The Very First Rule of Lifeh1>
- p>time pubdate datetime="2009-10-09T14:28-08:00">time>p>
- header>
- p>If there's a microphone anywhere near you, assume it's hot and sending whatever you're saying to the world. Seriously.p>
- p>...p>
- section>
- h1>Commentsh1>
- article>
- footer>
- p>Posted by: George Washingtonp>
- p>time pubdate datetime="2009-10-10T19:10-08:00">time>p>
- footer>
- p>Yeah! Especially when talking about your lobbyist friends!p>
- article>
- article>
- footer>
- p>Posted by: George Hammondp>
- p>time pubdate datetime="2009-10-10T19:15-08:00">time>p>
- footer>
- p>Hey, you have the same first name as me.p>
- article>
- section>
- article>
总结
div section article ,语义是从无到有,逐渐增强的。div 无任何语义,仅仅用作样式化或者脚本化的钩子(hook),对于一段主题性的内容,则就适用 section,而假如这段内容可以脱离上下文,作为完整的独立存在的一段内容,则就适用 article。原则上来说,能使用 article 的时候,也是可以使用 section 的,但是实际上,假如使用 article 更合适,那么就不要使用 section 。nav 和 aside 的使用也是如此,这两个标签也是特殊的 section,在使用 nav 和 aside 更合适的情况下,也不要使用 section 了。
对于 div 和 section、 article 以及其他标签的区分比较简单。对于 section 和 article 的区分乍看比较难,其实重点就是看看这段内容脱离了整体是不是还能作为一个完整的、独立的内容而存在,这里面的重点又在完整身上。因为其实说起来 section 包含的内容也能算作独立的一块,但是它只能算是组成整体的一部分,article 才是一个完整的整体。
因为其实有些时候每个人都有自己的看法,所以难免有难于决断的时候,怎么办?
在 HTML5 设计原理 中,有一条是专门用来解决类似情况的:
最终用户优先(Priority of Constituencies)
“In case of conflict, consider users over authors over implementors over specifiers over theoretical purity.” 一旦遇到冲突,最终用户优先,其次是作者,其次是实现者,其次标准制定者,最后才是理论上的完满。
推荐各位多读几遍 HTML5 设计原理,这才是纷繁世界背后的最终奥义。

html5的div元素默认一行不可以放两个。div是一个块级元素,一个元素会独占一行,两个div默认无法在同一行显示;但可以通过给div元素添加“display:inline;”样式,将其转为行内元素,就可以实现多个div在同一行显示了。

html5中列表和表格的区别:1、表格主要是用于显示数据的,而列表主要是用于给数据进行布局;2、表格是使用table标签配合tr、td、th等标签进行定义的,列表是利用li标签配合ol、ul等标签进行定义的。

固定方法:1、使用header标签定义文档头部内容,并添加“position:fixed;top:0;”样式让其固定不动;2、使用footer标签定义尾部内容,并添加“position: fixed;bottom: 0;”样式让其固定不动。

HTML5中画布标签是“<canvas>”。canvas标签用于图形的绘制,它只是一个矩形的图形容器,绘制图形必须通过脚本(通常是JavaScript)来完成;开发者可利用多种js方法来在canvas中绘制路径、盒、圆、字符以及添加图像等。

html5中不支持的标签有:1、acronym,用于定义首字母缩写,可用abbr替代;2、basefont,可利用css样式替代;3、applet,可用object替代;4、dir,定义目录列表,可用ul替代;5、big,定义大号文本等等。

html5废弃了dir列表标签。dir标签被用来定义目录列表,一般和li标签配合使用,在dir标签对中通过li标签来设置列表项,语法“<dir><li>列表项值</li>...</dir>”。HTML5已经不支持dir,可使用ul标签取代。

html5是指超文本标记语言(HTML)的第五次重大修改,即第5代HTML。HTML5是Web中核心语言HTML的规范,用户使用任何手段进行网页浏览时看到的内容原本都是HTML格式的,在浏览器中通过一些技术处理将其转换成为了可识别的信息。HTML5由不同的技术构成,其在互联网中得到了非常广泛的应用,提供更多增强网络应用的标准机。

3种取消方法:1、给td元素添加“border:none”无边框样式即可,语法“td{border:none}”。2、给td元素添加“border:0”样式,语法“td{border:0;}”,将td边框的宽度设置为0即可。3、给td元素添加“border:transparent”样式,语法“td{border:transparent;}”,将td边框的颜色设置为透明即可。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

Atom editor mac version download
The most popular open source editor

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools
