How to use <b> tag and <a> tag together in HTML?

19,412

Solution 1

Is that what you want ?

Your link is inside a body tag so what's wrong with b tag ? :-)

<b><a href="http://www.google.co.in">Search Engine</a></b>

Also

<a href="http://www.google.co.in"><b>Search Engine</b></a>

Question : But wouldnt it display : <b>Search Engine</b> instead of Search Engine ?

Answer: No. it won't , it would have been if you html encoded the < and >.

(you could have tried it yourself ;-))

Solution 2

this should do just fine

<b><a href="http://www.google.co.in">Search Engine</a></b>

DemoFiddle

Share:
19,412
PHPLover
Author by

PHPLover

Updated on June 04, 2022

Comments

  • PHPLover
    PHPLover almost 2 years

    I've following text in my webpage:

    <a href="http://www.google.co.in">Search Engine</a>
    

    I want this hyper text tobe in bold. At the same time this hyperlink should work. How to use <b> tag with <a> tag? Also I don't want to use CSS for making the text bold. I want to use only <b> tag for making the hyperlink text bold.

  • PHPLover
    PHPLover about 10 years
    Yes. Will the hyperlink work after residing the anchor tag into bold tag?
  • PHPLover
    PHPLover about 10 years
    My intention to ask a question was why it shouldn't work when I reside bold tag inside anchor tag?
  • Jukka K. Korpela
    Jukka K. Korpela about 10 years
    The two ways of nesting have the same effect by default, but the difference matters in styling. For example, if you set b { color: green } in CSS, then the link text will be green in the latter case, but not in the former (since the text is in an a element, which obeys settings for link colors).
  • smaqsood
    smaqsood over 3 years
    i need hyperlink with text bold and uppercase.