简体   繁体   English

html标签强大而正确的做事方式?

[英]html tag strong and correct way of doing things?

Take the code below, 拿下面的代码,

<strong><a href="#">Link</a></strong>

It will make the link bold. 它会使链接变粗。

Now consider this next example, does exactly the same thing, but which is the one to use from a SEO and semantic point of view? 现在考虑下一个例子,做了完全相同的事情,但从SEO和语义的角度来看哪个是使用的?

<a href="#"><strong>Link</strong></a>

There is nothing significant to choose between them. 他们之间没有什么重要的选择。

You should only use these if you want a particular link to have stronger emphasis. 如果您希望特定链接更加强调,您应该只使用这些。 If you just want bold links, then you should use a { font-weight: bold; } 如果你只想要粗体链接,那么你应该使用a { font-weight: bold; } a { font-weight: bold; } in your stylesheet. a { font-weight: bold; }在样式表。

In my experience, wrapping anchors around the text only, or else around the minimum markup required, minimizes browser bugs. 根据我的经验,仅在文本周围包装锚点,或者在所需的最小标记周围,最小化浏览器错误。

I respectfully disagree with Quentin's comment above. 我恭敬地不同意昆汀上面的评论。 <strong> offers true semantic value, while font-weight: bold; <strong>提供真正的语义值,而font-weight: bold; is by definition a visual semantic descriptor. 根据定义是视觉语义描述符。 In support of this assertion, here are links to W3C definitions for both along with the first sentence from each. 为了支持这个断言,这里有两个W3C定义的链接以及每个的第一个句子。

To get a sense of how deliberate the semantic meanings of elements like <strong> are, look at the definition changes for <b> and <strong> in the W3 documentation for changed elements in HTML5: www.w3.org/TR/html5-diff/#changed-elements 要了解像<strong>这样的元素的语义含义是多么刻意,请查看W5文档中对于HTML5中已更改元素的<b><strong>的定义更改:www.w3.org/TR/html5 -diff /#变元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM