Forum Moderators: not2easy

Message Too Old, No Replies

repeating font-family over and over again?

         

midoriweb

11:46 pm on Jan 17, 2007 (gmt 0)

10+ Year Member



I have a quick question.

In CSS, lets say I have the following code:

.productnamecolorSMALL { font-weight: bold; font-size: 10px; font-family: verdana,arial,helvetica,sans-serif; COLOR: #000000; }
A.productnamecolorSMALL { COLOR: #00c; TEXT-DECORATION: underline; }
A.productnamecolorSMALL:hover {COLOR: #0066FF; TEXT-DECORATION: underline; }

Is that coded correctly? Meaning... since I listed the .productnamecolorSMALL font-family in the first line, I don't, and shouldn't, repeat the font family for the other two lines correct?

midoriweb

12:01 am on Jan 18, 2007 (gmt 0)

10+ Year Member



Oh... one more question while I'm on it.

If I have the following in the top of my CSS file:

BODY { font-size: 12px; color: #000000; font-family: verdana,arial,helvetica,sans-serif; BACKGROUND-COLOR: #FFFFFF; margin: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; padding: 0; }
TABLE, TD { font-size: 12px; COLOR: #000000; font-family: verdana,arial,helvetica,sans-serif; }
TEXTAREA, INPUT { font-size: 12px; COLOR: #000000; font-family: verdana,arial,helvetica,sans-serif; }

Do I need to list a font-family for any other CSS attribute on the page? Since I already defined in the body I want to use a font-family of verdana, then every attribute I add from then on should use this font family correct? The only time I'll need to add a font-family is if I want to use a different font for a section of my site correct?

Setek

12:23 am on Jan 18, 2007 (gmt 0)

10+ Year Member



Is that coded correctly? Meaning... since I listed the .productnamecolorSMALL font-family in the first line, I don't, and shouldn't, repeat the font family for the other two lines correct?

No, you shouldn't, unless you wanted to override the

font-family
properties you've already set :)

However, since some properties (such as font) cascade, you could virtually do this:

body { font-family: Verdana, Arial, Helvetica, sans-serif; }

.. and everything on your website will be that font. Keep in mind this does not extend to form controls (

input
,
select
textarea
) and you must redefine the fonts for these selectors also.

Do I need to list a font-family for any other CSS attribute on the page? Since I already defined in the body I want to use a font-family of verdana, then every attribute I add from then on should use this font family correct? The only time I'll need to add a font-family is if I want to use a different font for a section of my site correct?

Oh, and I answered that above :) No, you don't need to redefine your

font-family
values except with form controls. And the only time you'll need to do it otherwise is when you want to use a different, font, yes :)

midoriweb

12:35 am on Jan 18, 2007 (gmt 0)

10+ Year Member



Thanks Setek :)

I'm guessing color can also cascade then right? So if I list a color in my body I won't have to repeat that for every class as well correct?

One more thing... here's my body:

BODY { font-size: 12px; color: #000000; font-family: verdana,arial,helvetica,sans-serif; BACKGROUND-COLOR: #FFFFFF; margin: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; padding: 0; }

But below that I have this:

TABLE, TD { font-size: 12px; COLOR: #000000; font-family: verdana,arial,helvetica,sans-serif; }

Is the line above even needed? I want my body and stuff inside my tables to have the same attributes. I'm guessing the 2nd like defining table and td isn't needed in my case.

Setek

1:52 am on Jan 18, 2007 (gmt 0)

10+ Year Member



Is the line above even needed? I want my body and stuff inside my tables to have the same attributes. I'm guessing the 2nd like defining table and td isn't needed in my case.

No, it's not technically needed - and if you are pushing IE into standards mode it's actually not needed.

See, IE has two modes: quirks and standards. When you have a full and correct doctype, defined on the first line without any characters before it, you have successfully pushed IE into standards mode. This saves you a lot of headaches, such as auto margins, not cascading properties into tables properly, and the box model, to name a few.

The interesting one I mentioned for your case was "not cascading properties into tables properly."

Without having IE in standards mode, a table that should be cascading

font-size
and
color
properly... doesn't. You should notice the
font-size
being the same font size as the default base size - which is usually 16px - and the
color
defaults to #000 (black.)

So in that case, you'd need to redefine your

color
and
font-size
properties to match the rest of the document.

However, if you're in standards mode you don't have to do anything!

So, if you remove the redefinitions for your

td
, and the table looks different on refresh, you've pushed IE into quirks mode. If you fix the doctype problem you should notice the table going back to how it looked before you took out the redefinitions, without redefining it :)

midoriweb

9:03 am on Jan 18, 2007 (gmt 0)

10+ Year Member



Thanks again :)

I have a doctype but not a full doctype... so IE goes into quirks. Therefore, I'll be leaving my CSS file the way it is. I had no idea about all this so thank for giving me all that information :)