Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > HTML / XHTML
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 06-29-2009, 10:51 PM
  #1
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
<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.
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 12:36 AM
  #2
coothead
~ bald headed old fart ~
 
coothead's Avatar
 
Join Date: Aug 2003
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 7,860
iTrader: (0)
coothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to behold
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:-
__________________
coothead is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 01:15 PM
  #3
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
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?
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 01:52 PM
  #4
silent viper
Fighter (Level 4)
 
silent viper's Avatar
 
Join Date: Aug 2008
Posts: 37
iTrader: (0)
silent viper is an unknown quantity at this point
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.
silent viper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 05:26 PM
  #5
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
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?
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 05:40 PM
  #6
silent viper
Fighter (Level 4)
 
silent viper's Avatar
 
Join Date: Aug 2008
Posts: 37
iTrader: (0)
silent viper is an unknown quantity at this point
Quote:
Originally Posted by jpfalet View Post
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.
silent viper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 09:35 PM
  #7
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
Yes, it is linked perfectly fine. All my other rules work, except for the font one in the body.
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 06-30-2009, 11:54 PM
  #8
Horus_Kol
Mod of the Underlay
 
Horus_Kol's Avatar
 
Join Date: Jun 2002
Location: At a desk, hooked up and ready to rock
Posts: 17,230
iTrader: (0)
Horus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of lightHorus_Kol is a glorious beacon of light
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...
Horus_Kol is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-03-2009, 02:33 PM
  #9
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
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...
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-03-2009, 02:42 PM
  #10
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
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?
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-03-2009, 02:46 PM
  #11
coothead
~ bald headed old fart ~
 
coothead's Avatar
 
Join Date: Aug 2003
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 7,860
iTrader: (0)
coothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to beholdcoothead is a splendid one to behold
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.
__________________
coothead is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-03-2009, 02:58 PM
  #12
silent viper
Fighter (Level 4)
 
silent viper's Avatar
 
Join Date: Aug 2008
Posts: 37
iTrader: (0)
silent viper is an unknown quantity at this point
Quote:
Originally Posted by jpfalet View Post
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.
silent viper is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-03-2009, 07:00 PM
  #13
jpfalet
Novice (Level 1)
 
Join Date: Jun 2009
Posts: 7
iTrader: (0)
jpfalet is an unknown quantity at this point
Quote:
Originally Posted by silent viper View Post
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.
jpfalet is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 07-03-2009, 07:51 PM
  #14
Pegasus
Extremely Flighty Admin
 
Pegasus's Avatar
 
Join Date: Nov 2001
Location: 35º South of Santa Claus
Posts: 21,386
iTrader: (0)
Pegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to allPegasus is a name known to all
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.
__________________


Decaf is the root of all evil...
HTMLForums Awards 2008
Pegasus is online now   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 05:47 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.