Web Design Forum: Using em for font size - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Using em for font size Why are links smaller?

#1 User is offline   mrsminkie 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 588
  • Joined: 23-December 09
  • Reputation: 21
  • Gender:Female
  • Location:South Yorkshire
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 06 January 2010 - 07:38 PM

Hi,

I'm using em for font size, line-height etc.... However, I've noticed that if I set my <p> font to 0.8em, and then <a> font at 0.8em, the <a> font is smaller. To compensate I'm having to make the <a> font 1em to be the same size as the 0.8em <p>.

Where am I going wrong here please?

thanks
0

#2 User is offline   ElanMan 

  • In, out, shake it all about...
  • PipPipPipPipPip
  • View gallery
  • Group: Members
  • Posts: 3,298
  • Joined: 11-March 08
  • Reputation: 54
  • Gender:Male
  • Location:Darlington
  • Experience:Nothing
  • Area of Expertise:Nothing

Posted 06 January 2010 - 09:10 PM

That's because em values refer to the font-size of the parent element.
1 em would make the <a> have the same size font as its parent, regardless of what the parent's em value was.
The parent's em value would refer to its parent's font-size.
If you get me :)
0

#3 User is offline   mrsminkie 

  • Expert
  • PipPipPipPip
  • Group: Members
  • Posts: 588
  • Joined: 23-December 09
  • Reputation: 21
  • Gender:Female
  • Location:South Yorkshire
  • Experience:Intermediate
  • Area of Expertise:Designer/Coder

Posted 06 January 2010 - 10:10 PM

View PostElanMan, on 06 January 2010 - 09:10 PM, said:

That's because em values refer to the font-size of the parent element.
1 em would make the <a> have the same size font as its parent, regardless of what the parent's em value was.
The parent's em value would refer to its parent's font-size.
If you get me :)


Hi, Yes I understand. I'm reducing the font size to 80% of it's parent.... As far as hierarchy is concerned - is each div within a div a child of it's parent...?? Excuse my terminology!
0

#4 User is offline   Wickham 

  • Web Guru
  • View gallery
  • Group: Moderators
  • Posts: 2,875
  • Joined: 11-June 09
  • Reputation: 257
  • Gender:Male
  • Location:Salisbury UK
  • Experience:Intermediate
  • Area of Expertise:Web Developer

Posted 07 January 2010 - 06:58 AM

Assume these styles:-
body { font-size: 1.0em; }
p { font-size: 0.8em; }
a { font-size: 0.8em; }


and this markup where the a tag is inside the p tag:-
<p>Text <a href="page2.html">Page 2</a></p>


The p tag reduces font size to 0.8em and the a tag reduces that by a further 0.8em so the link text is 0.8*0.8 = 0.64em.

It only applies where the tag with a font-size in em is inside another tag with a font-size in em, so if you have nested divs with the above styles, they will not affect the situation, but this would:-
div { font-size: 0.8em; }


<div id="content">
<div>Something inside</div>
</div>


Then each div would apply 0.8em so the nested div would be 0.64em; but coding the div tag with a font-size in em is unusual.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users