部分,文章或Div?和较小的文本在一节和文章标签? [英] Section, Article, or Div? and Smaller text in a section and article tag?

查看:81
本文介绍了部分,文章或Div?和较小的文本在一节和文章标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我去了w3schools 新的HTML5元素,发现了section和article标签。我的问题是,什么时候应该使用一个部分,文章或div标签,为什么我的文本会变小,当我使用一个部分和文章标签?像这样:

Recently I went to w3schools New HTML5 Elements and discovered the "section" and "article" tag. My question is when should you use a section, article or div tag and why does the text gets smaller when I use a section and article tag? Like so:

<section><h1>H1 tag in a section tag</h1></section>
<article><h1>H1 tag in an article tag</h1></article>
<h1>H1 tag in nothing</h1>

复制并粘贴到这里。 (只是为了方便起见)

Copy and paste in to here. (Just putting it there for convenience)

推荐答案

部分:

$ b $ b

When to use section:


section元素表示通用文档或应用程序
section ... section元素不是通用容器元素。当
需要一个元素用于样式目的或为了方便
脚本时,建议作者使用div元素。

The section element represents a generic document or application section…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.

Html5doctor有用的经验法则:

Helpful rules of thumb from Html5doctor:


  • 不要将其用作样式或脚本的钩子;这是 div

  • 如果文章 c $ c> aside 或 nav 是更合适的

  • 不要使用它,除非有自然

  • Don’t use it just as hook for styling or scripting; that’s a div
  • Don’t use it if article, aside or nav is more appropriate
  • Don't use it unless there is naturally a heading at the start of the section
  • Use article instead for syndicated content

article元素代表由
a在文档,页面,应用程序或网站
中自包含的组合,并且旨在可独立分发或重复使用
例如在联合。这可以是论坛帖子,杂志或
报纸文章,博客条目,用户提交的评论,
交互式小部件或小工具,或任何其他独立的内容项目

The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. 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

当没有其他元素可以更好地语义描述时,使用 div ,或者你需要一个语义无意义的钩子

Use div when no other element can semantically describe it better, or you need a semantically meaningless hook for styling.

h1 看起来不同的原因是因为个别浏览器呈现不同的样式。您可以将浏览器中的内容归一化,并使用 css重置处理默认浏览器样式表。

The reason the h1s look different is because individual browsers render them differently. You can normalize things across browsers, and deal with default browser style sheets with a css reset.

这篇关于部分,文章或Div?和较小的文本在一节和文章标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆