CSS font assigning

liunx

Guest
Okay.

I was wondering if there is somesort of a guideline or 'rule' for assigning fontsizes.

The main question is for me: when do you assign a font-family?
> normally I assign it in my CSS body{}. Which works just fine ofcourse
but what about child tags like h1 which I will assign to another font-family.

Does it at such a point makes more sense to assign a font-family to specific regions and not already in the body-tag?

I look forward for your reply.

Thank you in advance,

3PinterWassup 3Pinter...

First off, it doesn't really make much sense to assign a font family in the body element of your css since you will be using different fonts for your headings and your paragraphs.

My recomendation is to assign fonts seperatly between your <h>'s and <p>'s etc. for example...


p {
font-family: arial, veranda;
font-size: 12px;
}

h {
font-family: veranda, arial;
font-size: 14px;
}


(Just a note... you should list more than just two fonts in the font-family tag.)

Doing so eliminates any conflicts, and it also gives you more control over what fonts are displayed where.

Also, don't forget that you can use the <div> for even more control within your <body>.There's nothing wrong with assigning the basic (i.e.: most commonly used) font in the body tag, then you don't have to worry about assigning it to each element that uses that font. Then you can change the font for those elements that you want to be different. For instance...

<style type="text/css">
body {
font: medium times, garamond, serif;
}
/* use different font for headings */
h1,h2,h3,h4,h5 {
font-family: verdana, helvetica, sans-serif;
}
/* divs for code samples, i.e. <div class="code"> */
div.code {
font: small "courier new", courier, monospace;
}
</style>

Also, be sure to use a generic font in each case (the "serif", "sans-serif", and "monospace" above).Hmzzz,

So if I would summarize these two messages, would this be correct:

Don't assign a font-family in your body tag if you're using all the html tags like <p> <span> <div> <hn> <li> etc.
But if you don't you should include it into your body tag?

Further does any browser have 'an own opinion about the font use' as in assigning it in tags. So if you have a parent tag assign font X and the child tag assings Y, X is still used?

Thanks.

3PinterThe W3C recommends using relative units, medium and small are absolute
<style type="text/css">
body, table { /* table is not inherited in some older browsers */
font: 100% times, garamond, serif;
}
/* use different font for headings */
h1,h2,h3,h4,h5 {
font-family: verdana, helvetica, sans-serif;
}
/* each hx is different across browsers, set these rules for each hx */
hx {
font-weight:bold; /* not numeric values (ie 700) inconsistent in Opera */
font-size:1.2em;
margin:5px; /* varies greatly across browsers, set this value */
}
/* divs for code samples, i.e. <div class="code"> */
div.code {
font: smaller "courier new", courier, monospace;
}
</style>
The only consistent font-weight values to use are normal and bold. Other values are incorrect, particularly with smaller font sizes.
Opera has a font-weight that is slightly lighter than other browsers. The difference is too small to compensate.
 
Back
Top