 |
|
06-29-2009, 10:51 PM
|
|
#1
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
<font> in HTML vs font: in CSS...problem
Hello,
When I try to set a font in HTML it works, but if I set a rule in my CSS to set the same font, it doesn't. Here are the three things I do (not at the same time of course):
<font face="Verdana, Tahoma, Arial, Helvetica">
...
...
...
</font>
vs
body {
font-family: Verdana, Tahoma, Arial, Helvetica;
}
or even...
body {
font: Verdana, Tahoma, Arial, Helvetica;
}
Out of all of those, only the first can change the font in my browser...is this a CSS issue because, somehow, the browser has superiority over CSS, and HTML has superiority over the browser?
I would appreciate input.
Thanks.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 12:36 AM
|
|
#2
|
 |
|
~ bald headed old fart ~
Join Date: Aug 2003
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 7,860
|
Hi there jpfalet,
and a warm welcome to these forums.
The font element is deprecated and should no be used.
CSS will override the font element as this example shows...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<style type="text/css">
body, font {
font-family:'times new roman',serif;
font-size:36px;
color:#000;
}
</style>
</head>
<body>
<font face="Verdana, Tahoma, Arial, Helvetica,sans-serif" size="1" color="#f00">
<div>
CSS RULES OK
</div>
</font>
</body>
</html>
Further reading:-
__________________
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 01:15 PM
|
|
#3
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
Therefore, I should use the CSS over the HTML to change the font?
Or do I have to use the HTML to change it...I didn't quite get your answer.
But if you are saying that I should use the CSS, then why isn't it working as I explained?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 01:52 PM
|
|
#4
|
 |
|
Fighter (Level 4)
Join Date: Aug 2008
Posts: 37
|
You should try to use CSS to change the font whenever you can.
If you would copy and paste us the exact code that you are having issues with then we might be able to help you.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 05:26 PM
|
|
#5
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
I gave you my problem...I type this in my main.css:
body {
background: url(../_images/backTeal.gif);
text-align: center;
font: Verdana,Tahoma,Arial,Helvetica;
}
or
body {
background: url(../_images/backTeal.gif);
text-align: center;
font-family: Verdana,Tahoma,Arial,Helvetica;
}
and it doesn't work. The font does not change.
Whereas if I do it in the HTML, like this:
<font face="Verdana,Tahoma,Arial,Helvetica">
...
</font>
then it works...
There's nothing else to it. It's plain simple. Why doesn't the CSS work?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 05:40 PM
|
|
#6
|
 |
|
Fighter (Level 4)
Join Date: Aug 2008
Posts: 37
|
Quote:
Originally Posted by jpfalet
I gave you my problem...I type this in my main.css:
body {
background: url(../_images/backTeal.gif);
text-align: center;
font: Verdana,Tahoma,Arial,Helvetica;
}
or
body {
background: url(../_images/backTeal.gif);
text-align: center;
font-family: Verdana,Tahoma,Arial,Helvetica;
}
and it doesn't work. The font does not change.
Whereas if I do it in the HTML, like this:
<font face="Verdana,Tahoma,Arial,Helvetica">
...
</font>
then it works...
There's nothing else to it. It's plain simple. Why doesn't the CSS work?
|
I presume you are linking to a stylesheet instead of placing the CSS directly into the webpage?
Have you linked the stylesheet correctly?
Last edited by silent viper : 06-30-2009 at 05:46 PM.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 09:35 PM
|
|
#7
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
Yes, it is linked perfectly fine. All my other rules work, except for the font one in the body.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
06-30-2009, 11:54 PM
|
|
#8
|
 |
|
Mod of the Underlay
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 17,230
|
can you show us the whole HTML and CSS? there may be another rule somewhere interfering.
__________________
Personal Blog (and photos): HorusKol
Articles on Programming and Development (PHP/HTML/CSS, C/C++, more): RandomTweak
The great secret that no SEO agent wants you to hear: if you build your website using w3c accessibility guidelines and your content is written for people, you will do better for longer in search engines than any other method...
|
|
Add to del.icio.us
Can you digg it?
|
|
|
07-03-2009, 02:33 PM
|
|
#9
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
Wow, that would be too long, but let me tell you that:
1) there is nothing in my HTML which is using the <font> tag
2) and the only rules in my CSS which directly modify the formatting of the actual text are:
color:
font-size:
text-align:
Hope it helps...
|
|
Add to del.icio.us
Can you digg it?
|
|
|
07-03-2009, 02:42 PM
|
|
#10
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
Ok, I think I might have solved my problem.
By using:
font: Verdana,Tahoma,Arial,Helvetica;
it didn't work...but I did not realize that by doing:
font-family: Verdana,Tahoma,Arial,Helvetica;
...it did work...
so does that mean that you MUST use the "font" for single font faces and "font-family" for multiple ones like in my example?
|
|
Add to del.icio.us
Can you digg it?
|
|
|
07-03-2009, 02:46 PM
|
|
#11
|
 |
|
~ bald headed old fart ~
Join Date: Aug 2003
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 7,860
|
Hi there jpfalet,
without a link to your site or the full page code, starting at the DOCTYPE and
ending at the </html>, I am afraid that there is no way that we can help you. 
__________________
|
|
Add to del.icio.us
Can you digg it?
|
|
|
07-03-2009, 02:58 PM
|
|
#12
|
 |
|
Fighter (Level 4)
Join Date: Aug 2008
Posts: 37
|
Quote:
Originally Posted by jpfalet
Ok, I think I might have solved my problem.
By using:
font: Verdana,Tahoma,Arial,Helvetica;
it didn't work...but I did not realize that by doing:
font-family: Verdana,Tahoma,Arial,Helvetica;
...it did work...
so does that mean that you MUST use the "font" for single font faces and "font-family" for multiple ones like in my example?
|
font-family is for the font type and if you use the font: one then you must place in things like font size, font colour etc for example
font: Verdana 12px black;
At least I think thats how it works.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
07-03-2009, 07:00 PM
|
|
#13
|
 |
|
Novice (Level 1)
Join Date: Jun 2009
Posts: 7
|
Quote:
Originally Posted by silent viper
font-family is for the font type and if you use the font: one then you must place in things like font size, font colour etc for example
font: Verdana 12px black;
At least I think thats how it works.
|
Thanks, I think that answers my question.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
07-03-2009, 07:51 PM
|
|
#14
|
 |
|
Extremely Flighty Admin
Join Date: Nov 2001
Location: 35º South of Santa Claus
Posts: 21,386
|
Don't use commas when you're listing font families. That could be what was buggering up the code. You can use multiple families when you're using the short form font: info; I do it all the time. You just have to have it in the correct order. I believe you have it correct, jp - family, size then colour.
|
|
Add to del.icio.us
Can you digg it?
|
|
|
KEEP TABS |
|
SPONSORS |
| |
|
| |
|
|
| |
|