在HTML5中,可以在em标签中使用强标签吗? [英] In HTML5, is it ok to use a strong tag within an em tag?

查看:102
本文介绍了在HTML5中,可以在em标签中使用强标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在按照以下方式标记一些用户警报

I'm currently marking up some user alerts as follows

<em>You are in danger of exceeding your <strong>40GB</strong> download limit</em>

我发现吗?提示,尽管html有效,但这在语义上是无效的。但是在所有实例中嵌套em / strong标签真的不行吗?在我看来,上面的示例似乎是一种完全合理的用法-特别强调已经强调的内容的一个小节。但是,屏幕阅读器可以按原意来解释它,还是会使其混淆?

I've found other answers suggesting that, although valid html, this is not semantically valid. But is it really not OK to nest em/strong tags in all instances? The above example seems to me to be a perfectly reasonable use - to specifically emphasise a subsection of something that's already emphasised. But can screen readers interpret this as it's meant to be interpreted, or woudl it tend to confuse them?

推荐答案

允许使用就HTML而言,在< em> 中的< strong> 。但是,在您的问题的特定语义内,这不是最佳选择。

It's permissible to use <strong> within an <em>, in terms of HTML. However, within the specific semantics of your question, it wouldn't be the best option.

有人回答使用< b> code>并详细说明了为什么这样做是适当的,并且链接到规范以对其进行备份。

Someone answered advocating using <b> with a great explanation of why it's appropriate and a link to the specs to back it up.


b元素表示一段文字,在此范围内,出于功利目的,已经吸引了
的注意,但又没有传达任何额外的重要性
而没有其他声音或语气的含义,例如文档摘要中的关键
个词,评论中的产品名称,交互式文本驱动软件中的可操作的
个词或文章目录。

The b element represents a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede.

但是后来他们出于某种原因删除了答案。如果他们想重新发布他们的答案,我会很乐意投票并标记为答案。

But then they deleted the answer for some reason. If they want to repost their answer I'll happily upvote it and mark as the answer.

此外,对于您确实希望更加强调@Alohci的上述注释的一部分指出,在html5中嵌套< em> 标签是允许的

Also, for the case where you really do want to put stronger emphasis on a subsection of an alreday emphasised passage @Alohci's comment above points out that in html5 nesting <em> tags is permissible


不幸的是,< em> < strong> 的语义已更改来自HTML4的
HTML5中,这可能会影响您问题的答案。如果
对HTML5感兴趣,我建议您特别阅读
,这里是< em> 的新定义:
http://dev.w3.org/html5/spec/the- em-element.html

Unfortunately, the semantics of <em> and <strong> have changed in HTML5 from HTML4, and this may affect the answer to your question. If you are interested in HTML5, I recommend that, in particular, you read the new definition of <em> here : http://dev.w3.org/html5/spec/the-em-element.html

这篇关于在HTML5中,可以在em标签中使用强标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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