Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 

Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format



Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

CSS Tip:
Cross-Browser Font-Size

by Tom Dahm,
Chief Operations Officer,
NetMechanic, Inc.

  
December 1998
Vol. 1, No. 4
 • Design Tip
 • JavaScript Tip
 • CSS Tip
  

Since 80% of Web surfers are now using a 4th generation browser, Cascading Style Sheets are becoming a commonplace feature of HTML. Here's a tip that can save you some frustration when working with CSS: be careful where you put white space within a style rule. White space can cause problems if the value of your style property is specified as a unit of length.

For example, suppose you want to create a style rule that makes a block of text 24 points high. To do this, you might use the following style rule:

<DIV ALIGN="center"
   STYLE="font-size : 24 pt; color : red">
This is 24 pt text, right?
</DIV>

This renders the following text:

This is 24 pt text, right?

According to the CSS Specification, this isn't a legal rule. The standards don't allow for a space between the number and the unit. So "24pt" is legal syntax, but "24 pt" is not.

However, the two major browsers apply this rule differently. Netscape Navigator strictly applies the standard, and so ignores the rule. In addition, this syntax error prevents Navigator from correctly parsing the "color : red" rule as well. As a result any Netscape browser will display the code above as normal text.

Microsoft Internet Explorer does allow for a space between the number and the unit. If you're using Internet Explorer 3.0 or higher, you should see this text rendered in large red letters.

Who is correct here? Since the standards state that the number and the unit of measure cannot contain white space, Internet Explorer is allowing an illegal syntax. Keep that in mind if you build your Web pages using Internet Explorer. Style sheets that work under that browser may not work under Navigator.

If we re-write the style rule as follows, both browsers will display the text as intended:

<DIV  ALIGN="center"
   STYLE="font-size : 24pt; color : red">
This is 24 pt text, right?
</DIV>

This renders the following text:

This is 24 pt text, right?

Also note that Navigator's handling of this extra white space is quirky. In the case above, Navigator ignored the entire style rule. For other style properties, though, the result is a partial or erratic display of the style.

In any case, you should be able to avoid trouble in all browsers if you write your length values without white space.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2007,
Keynote NetMechanic
All rights reserved.