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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<FONT> tag 3

Status
Not open for further replies.

calista

Programmer
Jan 24, 2001
545
US
OK, I've read about why you shouldn't use the <FONT> tag, but what do you all use instead?

I've created a couple of CSS classes, and I have used them to modify the <FONT> tag because that seems the most logical one to use. (e.g. <FONT Class=&quot;Highlight&quot;>) If I use the class to modify <STRONG>,<EM>, or any other text tag, I get the attributes of that tag in addition to what the class does to it.

What is the best way to handle this?
 
If you want ALL of the text on the page to be Arial, for example, you could use:
Code:
BODY
{
   font-family: Arial;
}

There are times when you want all the text in the body of the page to be Arial, but all the text in your tables to be Times New Roman, bold. So:
Code:
TABLE
{
   font-family: Times New Roman;
   font-weight: Bold;
}

Otherwise, you may have several sections where classes and IDs are the way you want to go. Perhaps you want par.1 to be Arial and par.2 to be Tahoma. Where you could establish classes for each paragraph and encapsulate them in <DIV> or <SPAN> tags.

Basically, <FONT> is a depricated tag, which I believe means it could potentially be phased out of future HTML standards, therefore you want to try to get away from using it. Kevin
slanek@ssd.fsi.com
 
I understand what you're saying, and I appreciate the input. I will definitely keep this in mind.

But what about when you want only a few words here and there to have the special class? For example, I made a class to highlight in the full text the search terms the user searched for. I could apply the class to the <STRONG> tag if I wanted bold print, (and in this case I do), but what if I didn't?
 
I would make the class like this:
Code:
.highlight
{
   background-color: Yellow;
}

Then call it like this:
Code:
<DIV CLASS=&quot;highlight&quot;>The text to highlight</DIV> and the rest of the text...

You can use the &quot;highlight&quot; class anywhere you want. Kevin
slanek@ssd.fsi.com
 
Actually, it would be better the use the <SPAN> tag in the example above than the <DIV> tag. DIV is a block tag, SPAN is an inline tag, which is what you want if you only want to change the style (class) for part of a sentence.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Thanks, guys! Both of you were quite helpful. Kevin, I'll see you in the Cold Fusion forum! :)
 
Calista, I think tsdragon is right, I misled you. Correct me if I'm wrong, tsdragon, but what he's saying is that if you use div like I said, it would put a line break in your paragraph, whereas span would let you have some text, use the span, and have more text all on the same line.

Am I getting that right?

Yep, I'll see ya in the CF forum. ;-) Kevin
slanek@ssd.fsi.com
 
That is correct! The <DIV> and </DIV> tags will cause line breaks, whereas the <SPAN> and </SPAN> tags will not.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Note also that CSS attributes that are listed as &quot;block level attributes&quot; will not work in a <SPAN> tag.
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
if this helps you out, please use it

<style>
.highlight {color:white;text-decoration:none}
.highlight:hover {color:eek:range;text-decoration:underline}
</style>

<a href=&quot;blahblah.html&quot; class = &quot;highlight&quot;> HELLO </a>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top