简体   繁体   中英

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?

<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; } in your stylesheet.

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; 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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