Can hyperlink text in H2 be different font from rest of h2?

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can hyperlink text in H2 be different font from rest of h2?

Post by simonmlewis »

I have a H2 tag. It's styled with translucent background and a font size.
But I've been asked to put text below it, that is small. ie "click here for full range".

I tried this:

Code: Select all

 <div class='home-column-inner'>
  <a href='/link-here'>
  <h2>Title here<br/><a href='/link-here'>Click for full range</a></h2>
</div>
But I don't see a way of saying:

h2 { this font size }
h2 a { a smaller font size}.

Can it be done??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Can hyperlink text in H2 be different font from rest of

Post by simonmlewis »

Scratch that, it was becuase had two <a> tags in there, so it was all using that <a> reference.
Been one of those days!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
harman87
Forum Newbie
Posts: 4
Joined: Sat Jun 18, 2016 4:38 am

Re: Can hyperlink text in H2 be different font from rest of

Post by harman87 »

Yes, hyperlink text in H2 can be different from rest of non-linked H2s.

The reason is when you put anchor text in h2 tag, it overwrite the h2 style. So to keep hyperlink text same as normal h2 text you need to style the <a> tag with same font properties.
Post Reply