The Wayback Machine - https://web.archive.org/web/20081204102057/http://www.webreference.com:80/html/tutorial7/2.html


spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

I Shot the Serif

Size Does Matter


Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

Next in line comes the font-size property.

The font-size property

Property:font-size
Accepted values:An absolute or relative font size, a length, or a percentage
Initial value:medium
Applies to:All Elements
Inherited:Yes

The font-size property accepts various types of values. One is an absolute size. There are five absolute font sizes, called Mini, Toyota, Volvo, Cadillac and GMC. Oh OK, there are actually seven, and they're called xx-small, x-small, small, medium, large, x-large and xx-large. But you get the picture. medium is the default font size, and each absolute size is scaled by a constant factor.

A little interlude here: CSS1 defined that this factor should be 1.5, and stated that this might not be right for different media. The authors of CSS2 decided that this was too large for them and so reduced it to 1.2. As usual, the authors of Explorer and Navigator took a completely different stand on this, but you can expect the different absolute sizes to be larger or smaller than each other, since they have fixed values in both browsers (skipping ahead to something we'll discuss in a future tutorial, these are identical to the seven sizes used in <FONT SIZE="foo">, just in case you know what that is, which you shouldn't unless you've been cheating), but these values are relatively reasonable and will usually produce the desired effect with something like the following:

<P><SPAN STYLE="font-size: xx-large">xx-large</SPAN></P>
<P><SPAN STYLE="font-size: x-large">x-large</SPAN></P>
<P><SPAN STYLE="font-size: large">large</SPAN></P>
<P><SPAN STYLE="font-size: medium">medium</SPAN></P>
<P><SPAN STYLE="font-size: small">small</SPAN></P>
<P><SPAN STYLE="font-size: x-small">x-small</SPAN></P>
<P><SPAN STYLE="font-size: xx-small">xx-small</SPAN></P>

xx-large

x-large

large

medium

small

x-small

xx-small

The second type of font size is a relative size, and that can be either smaller or larger. As these should probably indicate to you, they make the font larger or smaller, compared to the value it initially had (more on initial values when we discuss inheritance and cascading, so just take my word on it for now). If the font had an absolute size, this will skip one absolute size up or down, i.e. if the font had a size of x-large, giving it a relative size of smaller will make it large, and so on. If the font size is not one of the seven absolute sizes, it is scaled down or up by a reasonable factor. Surprisingly enough, Internet Explorer 4.0 handles this quite well. Navigator 4.0, on the other hand, tends to be a bit unreliable, so don't depend on a smaller followed by a larger to get you back where you started, as illustrated by something like this:

<DIV STYLE="font-size: xx-large"><P>Some text</P>
<DIV STYLE="font-size: smaller"><P>Some text</P>
<DIV STYLE="font-size: smaller"><P>Some text</P>
<DIV STYLE="font-size: smaller"><P>Some text</P>
<DIV STYLE="font-size: smaller"><P>Some text</P>
<DIV STYLE="font-size: smaller"><P>Some text</P>
<DIV STYLE="font-size: smaller"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
<DIV STYLE="font-size: larger"><P>Some text</P>
</DIV></DIV></DIV></DIV></DIV></DIV></DIV>
</DIV></DIV></DIV></DIV></DIV></DIV></DIV>

The example starts off with an absolute size of xx-large and then makes it smaller six times (making the smallest line theoretically equivalent to xx-small) and then makes is larger seven times, which should give us one step larger than xx-large for the last line, as it is with Explorer. Navigator, however, gives us a much larger result in the end. But the desired effect (i.e. to make the font larger) is achieved.

You can also specify the font size as a percentage, which is similar to a relative size. The size is scaled by the percentage relative to the default, like this:

<DIV STYLE="font-size: x-large">
<P><SPAN STYLE="font-size: 200%">Double</SPAN> Normal <SPAN
STYLE="font-size: 50%">Half</SPAN>.
</DIV>

Double Normal Half.

Lengths as font sizes

Lastly, you can specify a font size as a length. A length is a special type of value in CSS, and we will discuss the various types of lengths in depth in a future tutorial. Suffice it to say, for now, that a length is a number, followed by a unit. One of the most useful units is the point, that is a popular unit of font size. The following example specifies various font sizes:

<HTML>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
 "http://www.w3.org/TR/REC-html40/loose.dtd">
<TITLE>Length Font Size Examples</TITLE>
<STYLE TYPE="text/css" MEDIA="screen">
#two { font-size: 2pt; }
#ten { font-size: 10pt; }
#twelve { font-size: 12pt; }
#fourteen { font-size: 14pt; }
#seventytwo { font-size: 72pt; }
.example { font-family: Garamond, Times, serif; }
</STYLE>
<BODY>
<P ID=two>2 point Serif</P>
<P ID=ten>10 point Serif</P>
<P ID=twelve>12 point Serif</P>
<P ID=fourteen>14 point Serif</P>
<P ID=seventytwo>72 point Serif</P>

So if it isn't your family and it isn't your size, maybe your weight is your problem? Or you just have the wrong style? Maybe you just have to face the fact that you're a variant...

Front Page123456789

http://www.internet.com

Produced by Stephanos Piperoglou

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Copyright 2008 Jupitermedia Corporation All Rights Reserved.

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
  Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A; with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Review: Lenovo ThinkPad SL300 · OCZ PC3-10666 Gold 2x1GB Review · Apple Recommends Antivirus for Macs


All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/html/tutorial8/
Created: Oct 20, 1998
Revised: Nov 3, 1998

Morty Proxy This is a proxified and sanitized view of the page, visit original site.