使用语义有意义标记背后的逻辑是什么?
它仅适用于屏幕阅读器软件吗?因为浏览器以相同的方式呈现语义和表示两种类型的标签。
例如:
对于我们的浏览器和 css 和
是相同的。语义标签相对于表现标签的目的是什么。
它仅用于屏幕阅读器还是为了更好地管理代码?
如果是针对开发人员的,strong
和 b
都可以在浏览器上产生相同的结果。
Is it only for screen reader software? because browser renders both type of tags semantic and presentational in same manner.
For example:
for browser for us and for css <strong>
and <b>
is same. what is the purpose to semantic tag over presentational tag.
is it for screen readers only or it's for better management of code?
if it's for developer strong
and b
both can produce same result on browser.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
语义标记允许脚本理解上下文。这可能有利于屏幕阅读器软件,但也有利于谷歌和其他搜索机器人。
根据 HTML 规范,和传达强调,而 和只是意味着“显示粗体”和“显示斜体”。 和应该在特别不需要强调的情况下使用。例如,将书名斜体化时。
当搜索机器人试图获得内容的语义理解时,可以合理地假设它们更倾向于语义标签。
Semantic markup allows scripts to understand context. This may be beneficial for screen reader software, but it will also be beneficial for Google and other search bots.
According to HTML specs, <strong> and <em> communicate emphasis, whereas <b> and <i> simply mean "display bold" and "display italic". <b> and <i> should be used in instances where emphasis is specifically not desired. For example, when italicizing a book title.
When search bots are trying to gain semantic understanding of content, it is reasonable to assume they give greater preference to semantic tags.
和
在这种情况下是一个糟糕的例子,因为它们在历史上只是以错误的概念使用。很多人开始用
将所有内容标记为粗体,从而破坏了初衷。例如,我的手机浏览器不会将
设为粗体(尽管标准建议在屏幕上将其加粗)。
语义标签背后的想法是提供一些有关内容的描述。因此,菜单项的
标签没有任何意义,而使用它来标记句子的一部分是有意义的,就像它的发音更大一样。
使用 HTML5 语义标签变得更有意义,因为页面的内容部分被清晰地概述,并且内容中的每个标签都是可用的元数据。搜索引擎已经很擅长这一点,但其他人却不然。
我建议阅读语义网的整个概念。
<strong>
and<b>
is a poor example in this case, as they are just historically used in a wrong notion. A lot of people started marking everything bold with<strong>
, thus destroying the original intent. My phone browser does not make<strong>
bold for instance (although the standards suggests making it bolder on screen).The idea behind semantic tags is to provide some description about the content. So
<strong>
tag for menu items does not make any sense, while it makes sense to use it to mark part of a sentence as if it was pronounced louder.With HTML5 semantic tags make a lot more sense, because the content part of the page is clearly outlined, and every tag inside the content is a usable meta data. Search engines are already good at this, but everyone else isn't.
I suggest reading about the whole concept of Semantic Web.
理论上,音频页面阅读器可以以不同的、更慢的、更强调的语气阅读
文本。它不会仅对
执行此操作,因为这只是图形表示的印刷提示。基于终端的浏览器可以使用下划线来重现
,作为粗体的替代方案,如果它在终端上不是可用的效果,原则上它不会对于印刷
来说这样做是有意义的。搜索引擎可以更加重视
编辑的单词。
在实践中,我认为这些例子中的任何一个都不会真正发生——正如 HeavyWave 所说,部分原因是几十年来的低质量标记已经消除了它们之间任何可以有用地绘制的差异——但它证明了哲学上的差异。
In theory, an audio page reader could read
<strong>
text in a different, slower, more emphasized tone of voice. It wouldn't do that for just<b>
because that's only a typographical hint for graphical presentation. A terminal-based browser could use underlining to reproduce<strong>
as an alternative to bold if it's not an available effect on the terminal, where is principle it wouldn't make sense to do that for typographical<b>
. A search engine could give more importance to<strong>
ed words.In practice, I don't think any of these examples actually happen — partly, as HeavyWave says, because decades of poor-quality markup have erased any difference between them that could usefully be drawn — but it demonstrates the philosophical difference.