Joho the Blog » Overriding Styles
EverydayChaos
Everyday Chaos
Too Big to Know
Too Big to Know
Cluetrain 10th Anniversary edition
Cluetrain 10th Anniversary
Everything Is Miscellaneous
Everything Is Miscellaneous
Small Pieces cover
Small Pieces Loosely Joined
Cluetrain cover
Cluetrain Manifesto
My face
Speaker info
Who am I? (Blog Disclosure Form) Copy this link as RSS address Atom Feed

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.)

Previous: « || Next: »

5 Responses to “Overriding Styles”

  1. 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%”>. :-)

  2. 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.

  3. 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…. :-)

  4. 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.

  5. 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.

Leave a Reply

Comments (RSS).  RSS icon