26

Possible Duplicate:
Is it right to add <span> tag inside <a> tag?

<a href="domainname"><strong>Its Me</strong></a> 

OR

<strong><a href="domainname">Its Me</a></strong>?

What is the difference between the two above?

Community
  • 1
  • 1
Codeobsession
  • 1,735
  • 4
  • 15
  • 12
  • 2
    I think you got good answers here already: http://stackoverflow.com/questions/7427177/is-it-right-to-add-span-tag-inside-a-tag. This question isn't fundamentally different... Try to understand those answers first and read about the HTML specification – Lukas Eder Sep 16 '11 at 11:49
  • Same difference like between "A in B" and "B in A". – c69 Sep 16 '11 at 11:50

3 Answers3

16

<strong><a href="domainname">Its Me</a></strong> is the recommended XHTML syntax, but it doesn't matter.

But there is no real difference between the two. It's like asking what is the difference between
5 + 2 and 2 + 5, there is no difference in logic, just in syntax.

AndroidHustle
  • 1,794
  • 5
  • 24
  • 47
  • why? do you have a reference? – Clive Sep 16 '11 at 11:53
  • found this http://www.wikicreole.org/wiki/Creole1.0#section-Creole1.0-BoldAndOrItalicLinks, it has a section about it – AndroidHustle Sep 16 '11 at 11:56
  • Thanks! Not sure I agree with that, I still think that because `` is a semantic tag that it depends what element you're trying to put the emphasis on. – Clive Sep 16 '11 at 11:59
  • 6
    If looking for "recommended XHTML syntax", then W3C is the only authority IMO. What is this wiki? – Lukas Eder Sep 16 '11 at 11:59
  • 5
    It's "some Wiki" that brought up the subject, I'm not trying to write a paper here. – AndroidHustle Sep 16 '11 at 12:04
  • @AndroidHustle: Don't take this criticism too personal. Stack Overflow aims to be a high quality Q&A, so people expect to find well-founded answers here. Many readers will be curious about your sources... So with that in mind, you get more upvotes if you cite more trustworthy sources – Lukas Eder Sep 16 '11 at 12:18
  • @Lukas Eder: Since I didn't know of or find a section where W3C brought up this subject I listed another reference, he asked for it, then it's up to him to evaluate its credibility. And to be honest, the reason for it not being mentioned on W3C at all is probably because it's a highly trivial query to start with. But if you want to play "community-police" go right ahead, down rate my answer all you want. – AndroidHustle Sep 16 '11 at 12:38
  • @AndroidHustle: Relax. I didn't downvote. – Lukas Eder Sep 16 '11 at 12:42
  • @Lukas Eder: Ok, I'm sorry. I can see how you doubt the Creole Wiki credibility, if I had found a better source I would have referenced that, but I didn't. – AndroidHustle Sep 16 '11 at 12:49
6

Both are perfectly valid.

<strong> is used to give semantic weighting to the contained element, so I guess it's a choice between whether it's the link or the link's content that you're trying to give emphasis to.

Personally I always put <strong> inside <a> but that's probably just a habit I've picked up over the years.

Clive
  • 36,918
  • 8
  • 87
  • 113
-6

No visual different, but <strong> tag is text formatting tag.

Look at my example:

<html>
    <body>
        <div style="color:red;"><strong>hello</strong></div>
        <strong><div style="color:red;">hello2</div></strong>
        <strong><div style="color:red;">hello3</strong></div>
    </body>
</html>

Last 2 lines are incorrect, but in visual all lines are strong (thanks to your browsers). Be smart, write clean code! ;-)

Tadas Kvedaras
  • 551
  • 3
  • 9
  • 3
    and are text formatting tags. and are not text formatting tags, they are semantic tags that get interpreted by visual browsers as bold and italic. – Mixologic Aug 17 '13 at 03:25