html – 章节,文章或Div?和一小段文章和文章标签?

html – 章节,文章或Div?和一小段文章和文章标签?,第1张

概述最近我去了w3schools New HTML5 Elements,发现了“section”和“article”标签.我的问题是什么时候应该使用一个部分,文章或div标签,为什么我使用部分和文章标签时文本变小?像这样: <section><h1>H1 tag in a section tag</h1></section><article><h1>H1 tag in an article tag< 最近我去了w3schools New HTML5 Elements,发现了“section”和“article”标签.我的问题是什么时候应该使用一个部分,文章或div标签,为什么我使用部分和文章标签时文本变小?像这样:
<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>

复制粘贴到here.(只是把它放在方便)

解决方法 When to use section:

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.

Helpful rules of thumb from Html5doctor:

>不要使用它作为样式或脚本的钩子;这是一个div
>如果文章,旁边或导航更合适,不要使用它
>不要使用它,除非在本节开始时自然有一个标题
>使用文章代替联合内容

When to use article:

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,或者您需要一个语义上无意义的钩子来进行样式化.

h1s看起来不一样的原因是因为各个浏览器使它们不同.您可以在浏览器之间规范化事物,并处理带有css reset的默认浏览器样式表.

总结

以上是内存溢出为你收集整理的html – 章节,文章或Div?和一小段文章和文章标签?全部内容,希望文章能够帮你解决html – 章节,文章或Div?和一小段文章和文章标签?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1090474.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存