Making part of a sentence a different colour

aka Rohan's picture

He has: 200 posts

Joined: Feb 2006

Ok this is basically what I'm after:

"This bit is black this bit is red and now it's back to black"

What's the best way to do this in xhtml strict 1.0? I need to do this both in tags (for a main description bit) and in

  • for a list.
  • Do I just add tags around the bit I want coloured?... I'd rather keep formatting out of the main code though.

    Cheers.

    Megan's picture

    She has: 11,421 posts

    Joined: Jun 1999

    No, no, no font tags! No font tags ever.

    The question you need to ask is this: Why is it red? Is it because it is strong or emphasized? If so, use or with a class that describes the purpose of the text. If there is no reason why the text is red, you can use a with a class to style it.

    The class name should describe why it is red, not that it is red. So for example you could use instead of .

    aka Rohan's picture

    He has: 200 posts

    Joined: Feb 2006

    Awesome, thanks guys. That works a treat Smiling

    demonhale's picture

    He has: 3,278 posts

    Joined: May 2005

    To further megans explanation, it's like this...

    "This bit is black this bit is red and now it's back to black"

    on css:
    p {color:#000;}
    .alert {color: red;}

    Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.