Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Font Tag Depricated in HTML 4.0? 2

Status
Not open for further replies.

powahusr

Technical User
Jan 22, 2001
240
US
I just ran an HTML Validation tool against my HTML Syntax and I got a message that say's the "FONT" tag is depricated in HTML 4.0, consider using CSS. Whats this mean? I do use CSS for my Font properties, however, I have to specify the Class or Style attribute within my Font tag to use CSS with my content. How do I use CSS without the Font tag?

Thanks in Advance!!!
 
use <SPAN class=&quot;nameOfClass&quot;>text here</span> instead.

Using span is a good idea if you want newer browsers to render your page faster (by like a half millisecond) if they validate correctly that is.

Gary Haran
==========================
 
You can also use the
Code:
class=&quot;myClassName&quot;
on any of your other elements (<p>,<td>) etc. Or even redefine those elements in your stylesheet for a more global effect.
 
dwarf's comment makes lots of sense. Use span only when you really have no choice, it keeps your code nice and clean to use it the least possible! :)

Gary Haran
==========================
 
Excellent replies, you folks are the best.

Just one last question...

Hypothetically, Say I want a different font face/color for two different sentences or words within the same element, how can I do that if I specify the &quot;class=name&quot; within the cell holding the sentences?

Example:

<td class=name>
Sentence One, I would like in Red text. Sentence Two, I would like in Blue text.
<td>

In this case, all text will be the same color, because the default color will be whatever is specified in the class &quot;Name&quot;.

Any suggestions?

Thanks again!!!

 
This is the instance where you would use Gary's original suggestion and place <span> tags where you once would have had <font> tags:

Code:
<td class=name>
    <span class=&quot;redText&quot;>Sentence One, I would like in Red text.</span><span class=&quot;blueText&quot;>  Sentence Two, I would like in Blue text.</span>
<td>
 
I figured that was where the <span> tag would come into play, just wanted to make sure.

Once again, thanks a lot for your help!!
 
oh yeah one last thing! :)

Cascading Style Sheet (CSS) usually inherits from parents so if you have a span it will only override what properties you give ask it to.

<div style=&quot;font-size:18px;&quot;>The whole text is the same size but only one word is <span style=&quot;font-weight:bold;&quot;>bolded</span> in this example</div>

So you can use spans to only affect a few properties of a few words/characters! :)

Gary Haran
==========================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top