CSS question: not understanding a...

User 597929 Photo


Registered User
1,332 posts

I'm modifying an existing style sheet and this (to me) somewhat complex font declaration has some elements in it I don't understand (even after reading about the syntax at w3school). Here's the syntax:

font: 62.5% Georgia, "Times New Roman", Times, Serif; /* Resets 1em to 10px */


I understand that "Times New Roman" invokes the specific font, and Times is the family-name and Serif is the generic-family.

What is this 62.5% Georgia doing? I know you can specify a font-size using a percentage, but Georgia? Why is that in there?

The other question is based on the included comment: how did they come to that value (1em to 10px) from the provided syntax?

Many thanks in advance.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 355448 Photo


Ambassador
3,144 posts

Spinny,

The preferred font is listed first (Georgia in this case) and then the others in order of preference.

Here is a link that explains em http://webdesign.about.com/od/fonts/qt/ … m.htm?nl=1

Here is a quote from that page that will help explain the 1em to 10px statement, but I think the comment is not always true.

But how tall is the default size? There is no way to be 100% certain, as customers can change their default font size in their browsers, but since most people don't you can assume that most browsers have a default font size of 16px. So most of the time 1em = 16px.


.65*16=10.4

Percentages are based on surrounding text, so I also do not understand why 65% unless there is another font setting before this one that sets the overall font size. If this setting is in a class or ID, it may be based on something defined higher up in the CSS file.

Hope some of my rambling helps.
User 597929 Photo


Registered User
1,332 posts

Okay, I got that, then. Ten is exactly 62.5% of 16. What threw me is there's no comma between the percentage and the Georgia element, so I read that as applying only to "Georgia" as one compound item. I was trying to read it as: "size Times New Roman to be 62.5% of Georgia." I thought elements in a compound font declaration always had to be separated by commas.

Thanks, that helps a lot.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 355448 Photo


Ambassador
3,144 posts

Spinny,

Here is something I just copied from W3Schools:

font:italic small-caps 900 12px arial;

That example shows 5 settings for that declaration.

The font property sets all the font settings in a single declaration.
font-style
font-variant
font-weight
font-size/line-height
font-family
caption
icon
menu
message-box
small-caption
status-bar

User 597929 Photo


Registered User
1,332 posts

Thanks, Bill. I don't know where I got the idea there had to be commas, guess I'm hallucinating or something. :P

It appears the order isn't important, nor do you need placeholders for missing elements. Guess the parser is smart enough to assign values by type.
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 355448 Photo


Ambassador
3,144 posts

Spinny,

I have never seen anything that said the order was specific, but then I haven't read the standards on the W3C site. Every example I remember has had them in this order, but no place holders needed for the missing items.

As for the hallucinations, I am not qualified to answer that question. Those that deal in that field make a lot more money than I. :lol:

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.