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

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

andynic

Thread Starter
Joined
May 25, 2007
Messages
425
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
 

JiminSA

Jim
Joined
Dec 15, 2011
Messages
3,407
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;)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

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 807,865 other people just like you!

Latest posts

Staff online

Top