Joho the Blog
An Entry from the Archives

« My Unbecoming Obsession with The Face || Back to Blog | GoogleShare »

November 23, 2002

Overriding Styles

Aha! I just learned how to override the definitions in a CSS style sheet!

Here's the problem. I use a CSS style sheet to define the properties of the HTML elements on this page. In fact, I load four style sheets with different definitions and let you click on the "Are you color blind?" link at the top of the page to determine which style sheet is in effect. The style sheet defines the <p> element as having brown text. If I want some portion of the text to have a different color — as in the final paragraph of the entry below with the picture of Michael Jackson — the following will not work:

<p><font color="red">this should be red</font></p>

The CSS definition overrides the local change. But, if you express the font change in the syntax of a CSS definition, it works:

<p><font style="color: red">this should be red </font></p>

This is explained in more detail than I could understand by David Baron. And here I learned how to do a relative size decrease:

<p><font style="font-size: 80%">This should be 80% the size of the rest of the text </font></p>

Woohoo! Sure, I should have known this, but then would I have gotten the same kick out of learning it?

(No need to tell me that "<font>" statements are no longer considered acceptable, um, I mean they're being "deprecated." I'm not ready to span the gap yet.)

Posted by D. Weinberger at November 23, 2002 11:48 AM


Comments

Okay, I won't remind you that the FONT tag is considered harmful, but I will point out that you could accomplish exactly the same thing and be considered much more of a CSS ninja if you use <span style="font-size: 80%">. :-)

Posted by: ralph | November 23, 2002 12:12 PM


I meant my oh-so-clever "not ready to span the gap" comment to indicate that I knew about spans but for some stupid reason decline to use them.

You are, of course, right.

Posted by: David Weinberger | November 23, 2002 12:38 PM


Zinnnnnggg!!!

(That's the sound of a clever pun going right over my head. Sorry about that! Damn, I'm usually better than that at puns.... :-)

Posted by: ralph | November 23, 2002 12:42 PM


or you can just add that style directly to the

, if you want the whole paragraph to be red, or small, or whatever. less markup, which is always a good thing.

Posted by: elaine | November 23, 2002 04:09 PM


Elaine, you've gone all literal on us! According to The Source, you meant that we could just add the style to the paragraph tag, thus properly deprecating the font tag.

But I like font tags! I think of fonts as their own objects, not as mere properties of other objects.

Posted by: David Weinberger | November 23, 2002 08:33 PM


Post a comment

Guidelines for Commenting

Basically, you can say what you want. (Click here for the fine print.)

If you haven't left a comment here before, your comment may be put into a queue for me to approve. Sorry for the delay. Blame the damn spammers.