DotDragnet
February 07, 2012, 03:08:32 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Help decide how we fund DDN and where we take the community from here. Post in the thread all about it: http://www.dotdragnet.com/forum/index.php/topic,4368.0.html
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: CSS Font Sizes  (Read 3854 times)
Jeewhizz
DDN Contribs
Hero Member
*****
Posts: 1626



View Profile Awards
« on: August 09, 2007, 02:31:32 PM »

Saw this on a mailing list I am on - I wasn't aware of it, and thought i'd share!

Quote
If you want good font size control, set the font size of your body to 62.5%
This should effectively give you a starting size of 10px. Then you can
use the magic of ems to scale your fonts with pixel perfection.
1.6em gives you 16px font.
1.2em gives you 12px font and so on.

Even though you have font sizing to the pixel, it's still able to be
changed by the browser as desired.

big grin
Logged

Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2212



ap4a.uk ap4a
View Profile WWW Awards
« Reply #1 on: August 09, 2007, 02:47:25 PM »

Make sure you keep an eye on inheritance. For example, if you set list items to 1.2em and have nested lists the nested list items will be larger than their parent list items.

Personally, unless I'm going to be setting box widths in ems, I set the font on the body to 75% (12px in most Windows and Mac browsers) so that text is readable without having to have multiple settings (10px is very often far too small for most people, and so a setting over 62.5% generally needs to be overridden elsewhere in the CSS).


Saw this on a mailing list I am on - I wasn't aware of it, and thought i'd share!

Quote
If you want good font size control, set the font size of your body to 62.5%
This should effectively give you a starting size of 10px. Then you can
use the magic of ems to scale your fonts with pixel perfection.
1.6em gives you 16px font.
1.2em gives you 12px font and so on.

Even though you have font sizing to the pixel, it's still able to be
changed by the browser as desired.

big grin
Logged

JasonD
Global Moderator
Hero Member
*****
Posts: 529



View Profile Awards
« Reply #2 on: August 09, 2007, 03:00:23 PM »

Eh? Why complicate what is already a simple calculation? Sticking with your assumption of 16px default:

0.625em = 10px
0.75em = 12px.
1em = 16px (only worth typing if default style for an element changes the size)

This level of math is not beyond most peoples abilities. Plus you won't get extra large text if the browser has a minimum font size > 62.5% of default.
Logged
Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2212



ap4a.uk ap4a
View Profile WWW Awards
« Reply #3 on: September 02, 2007, 04:05:36 PM »

16px isnt exactly default though

Really? Not even in Windows? Nor more recent Macs?

Quote
and setting to 62.5% does the job of making it more consistant over all browsers.

How does it?
Logged

samhs
Administrator
Hero Member
*****
Posts: 1669



View Profile WWW Awards
« Reply #4 on: September 02, 2007, 04:14:39 PM »

I tend to set to 66% as the base size, then assume 1em is roughly equiv to 10pt/10px. Not had a client complain yet.

Sam
Logged

Loose adj a not held together; not fastened or firmly fixed in place
Lose verb to misplace something. To fail to keep or obtain something, especially because of a mistake, carelessness, etc.
---
Blog: www.ohwrite.co.uk
Twitter: www.twitter.com/samhs
Mr Anderson
DDN Contribs
Hero Member
*****
Posts: 2212



ap4a.uk ap4a
View Profile WWW Awards
« Reply #5 on: September 02, 2007, 04:18:59 PM »

I tend to set to 66% as the base size, then assume 1em is roughly equiv to 10pt/10px. Not had a client complain yet.

I generally use 75% which is roughly 12px. Saves too much faffing about, unless I'm intending to use ems for box dimensions in which case I'll use 62.5%.
Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2006-2008, Simple Machines Valid XHTML 1.0! Valid CSS!