何时使用hr元素在语义上是正确的? [英] When is it semantically correct to use the hr element?

查看:145
本文介绍了何时使用hr元素在语义上是正确的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HTML5参考资料表示,


hr元素表示段落级别的主题突破,例如故事中的情景变化,或者在参考书的某个部分内转换到另一个主题。

该描述不足以描述对我来说。我在我的HTML文档中使用 hr 元素作为分隔内容的一种方式。这是正确的?



任何人都可以举几个例子说明何时使用它(除了所示的例子)以及何时使用 CSS 风格取而代之?

 < p>关于国内小猫< p>段的段落; / p为H. 
< p>关于小猫喜欢的食物的段落< / p>
< p>关于小猫玩耍的段落< / p>
< hr>
< p>段落关于我工作的一天< / p>

如果您想在图片和内容之间分开主题,我相信这也是适当的。

 < img src =/ img / kitten.jpgalt =小猫玩球> 
< img src =/ img / kitten1.jpgalt =小猫喝牛奶>
< hr>
< img src =/ img / zebra.jpgalt =斑马在野外>

新使用 hr 似乎只是用于区分HTML中的主题。如果你发现你的内容连接良好,不要觉得你需要使用标签。


The HTML5 reference says that

The hr element represents a paragraph-level thematic break, e.g. a scene change in a story, or a transition to another topic within a section of a reference book.

That description is not enough descriptive to me. I use the hr element in my HTML documents as a way to separate content. Is this correct?

Could anyone give a few examples on when to use it (apart from the examples shown) and when to use CSS styling instead?

解决方案

It's proper to use it when you have, say, several paragraphs with two distinct themes.

<p>Paragraph about domestic kittens</p>
<p>Paragraph about kittens' favourite foods</p>
<p>Paragraph about kittens' playfulness</p>
<hr>
<p>Paragraph about my day at work</p>

If you'd like to otherwise separate themes among images and content, I believe this is also appropriate.

<img src="/img/kitten.jpg" alt="kitten playing with ball">
<img src="/img/kitten1.jpg" alt="kitten drinking milk">
<hr>
<img src="/img/zebra.jpg" alt="zebras in the wild">

The new use of hr seems to just be for distinguishing topics within HTML. If you find that your content is well-connected, don't feel that you need to use the tag.

这篇关于何时使用hr元素在语义上是正确的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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