1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: change text color on the fly -- deprecated font tag

Discussion in 'Web Design & Development' started by andynic, Apr 11, 2015.

Thread Status:
Not open for further replies.
Advertisement
  1. andynic

    andynic Thread Starter

    Joined:
    May 25, 2007
    Messages:
    386
    Hi,

    Formerly, I would change text color on the fly in a simple though clumsy way like this and it passed W3 validation:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Uitgeverij Tobi Vroegh</title>
    </head>
    <body >
    <p>this is in  black; <font style="color:red">and this is in red; </font><font style="color:black"> and back to black."</font></p>
    </body>
    </html>
    
    Now if I change the DOCTYPE so that it is HTLM5, namely: <!DOCTYPE HTML>
    W3 validation gives me this error: The font element is obsolete. Use CSS instead.

    Is there an easy way to have different colors within the same paragraph or line as in the example above?
    Thanks for your help.
    Andynic
     
  2. colinsp

    colinsp

    Joined:
    Sep 5, 2007
    Messages:
    2,292
    First Name:
    Colin
  3. JiminSA

    JiminSA

    Joined:
    Dec 15, 2011
    Messages:
    3,388
    First Name:
    Jim
    Hi Andy, you could do it via your style sheet css ...
    Code:
    .red
    {
    color:red;
    }
    
    
    ... and your html changed to ...
    Code:
    <p>this is in  black; <span class="red">and this is in red; </span> and back to black.</p>
    (I'm assuming that your default paragraph styling is black.)
    Woops:eek: Colin answered just ahead of me - so you have a choice of solution;)
     
  4. andynic

    andynic Thread Starter

    Joined:
    May 25, 2007
    Messages:
    386
    Thanks for the replies which solved the problem
    Andynic
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1146418

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice