重要吗在<强>?

发布于 2024-08-20 02:43:01 字数 481 浏览 3 评论 0原文

重要吗

<p><strong><em>Some text</em></strong></p>

中的 中的 ?

<p><em><strong>Some text</strong></em></p>

哪个在语义上是正确的并且更容易理解?

更新:

屏幕阅读器在这两种情况下会如何表现?

Does it matter <strong> in <em>

<p><strong><em>Some text</em></strong></p>

or <em> in <strong>?

<p><em><strong>Some text</strong></em></p>

Which is semantically correct and more accessible?

Update:

How screen reader would behave in both situation?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

ぶ宁プ宁ぶ 2024-08-27 02:43:01

语法正确,但语义不正确。 可以说是 的“高阶”形式。如果您正在寻找 的效果,请使用 CSS。请记住,不要因为元素的外观而选择元素,而是因为它们的含义。

Syntactically correct but not semantically correct. <strong> is an "higher order" form, so to speak, of <em>. If you're looking for the effect of <b> and <i>, use CSS. Remember to not choose elements because of how they look but what they mean.

栖迟 2024-08-27 02:43:01

只要您不混淆结束标签的顺序,您列出的两种方式在标记方面都是完全正确的。这是不正确的:

<p><em><strong>Some text</em></strong></p>

Both ways you have listed are perfectly correct markup-wise, as long as you're not mixing up the order of the closing tags. This would be incorrect:

<p><em><strong>Some text</em></strong></p>
吃素的狼 2024-08-27 02:43:01

根据 w3 strong强烈强调。这意味着 emstrong 不应在语义上一起使用,因为 strong 已经是 em

如果您认为强烈强调应该是粗斜体,我认为您应该添加一个 css 声明,在其中将强调样式设置为粗体斜体。

According to w3 strong is strong emphasis. That means that em and strong should not be used together semantically as the strong is already an em.

If you believe that strong emphasis should be bold italic I think you should just add a css declaration in which you style the strong as bold italic.

烟雨扶苏 2024-08-27 02:43:01

如果您关心语义,则应避免在元素上同时使用 emstrong

强:渲染为强强调
文字

(via)

如果您关心有效的 HTML,那么这两种解决方案都很好且有效。

If you care about semantic meaning, you should avoid having both em and strong on an element.

Strong: Renders as strong emphasized
text

(via)

If you care about valid HTML, both solutions are fine and valid.

风柔一江水 2024-08-27 02:43:01

从视觉效果的角度来看,这并不重要。

在语义上,这很重要,因为您在同一元素(某些文本)中使用强调和强烈强调。这与在某些地方使用 h1 相同,只是因为您想要大文本,而不是因为它们是标题。

EM:表示强调。

STRONG:表示更强的强调。

来源

短语元素的呈现
取决于用户代理。一般来说,
可视化用户代理呈现 EM 文本
斜体和粗体文本。
**语音合成器用户代理可能
改变合成参数,例如
相应的音量、音高和速率。

所以要小心。使用 CSS 来完成视觉效果,而不是标记。

In a visual effect perspective, it doesn't matter.

In semantic meaning, it matters since you're using emphasis and strong emphasis in the same element (Some text). It's the same as using h1 in some places just because you want big texts and not because they're titles.

EM: Indicates emphasis.

STRONG: Indicates stronger emphasis.

Source

The presentation of phrase elements
depends on the user agent. Generally,
visual user agents present EM text in
italics and STRONG text in bold font.
**Speech synthesizer user agents may
change the synthesis parameters, such
as volume, pitch and rate accordingly.

So beware. Use CSS to acomplish visual effects, not markup.

゛清羽墨安 2024-08-27 02:43:01

在 (X)HTML5 中,定义/含义为:

因此原则上这些元素可以一起使用。

要获得想法,请考虑大声朗读文本(不过取决于语言):em 可能会改变语调(重音),strong 可能会增加响度。

我认为从语义上讲,如果您使用 foofoo;至少我在规范中找不到任何相关内容。

In (X)HTML5, the definitions/meanings are:

  • em: represents stress emphasis of its contents (changes meaning of sentence);
  • strong: represents strong importance for its contents (doesn't change meaning of sentence).

So these elements can be used together in principle.

To get an idea, think of reading a text out loud (depends on language, though): em might change the intonation (stress), strong might increase loudness.

I think semantically it makes no difference if you use <strong><em>foo</em></strong> or <em><strong>foo</strong></em>; at least I couldn't find anything related in the specification.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文