If the name of the font family has more than one word, enclose it in quotes. Here are
some examples of CSS rules using
font-family:
body { font-family: Arial, sans-serif; }
h1 { font-family: “Courier New”, monospace; }
h2 { font-family: “Times New Roman”, serif; }
You’ll learn more about font families and how to use them in Hour 8.
A Simple Style Sheet
Using just the simple properties and values you’ve learned so far this hour, you already can
create a basic style sheet; an example of a complete style sheet is shown in Listing 2.1.
LISTING 2.1 A Basic Style Sheet with Color, Size, and Font Declarations
/* basic-2.1.css */
/* Written by Kynn Bartlett <> */
body { font-family: Arial;
color: black;
background-color: white; }
/* I think Verdana looks nice for headlines */
h1, h2, h3, h4, h5, h6 { font-family: Verdana, sans-serif; }
/* This puts the second level heading in red */
h2 { color: red; }
address { font-family: Verdana, sans-serif;
font-size: smaller; }
You can find a copy of this style sheet on the Web at
/>Linking a Style Sheet to an HTML Page
A style sheet by itself doesn’t really do anything except sit there on your hard drive or
Web server. If you try to load it in your browser, it will just display as plain text. To actu-
ally use the CSS rules, you need to have a file with markup, such as an HTML page, and
you need to add an HTML tag to link the CSS file to the Web page.
A Simple HTML Page for Styling
Listing 2.2 shows the structure of a basic HTML page like one you might find on the
Web; it has headlines, paragraphs, horizontal rules, and even a little table on the side. You
32 Hour 2
05 0672324091 ch02 6/13/02 10:39 AM Page 32
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
can download a copy of this file from />because that’s easier than typing in the whole thing.
LISTING 2.2 A Simple HTML File That Needs Styling
<! basic-2.2.html >
<html>
<head>
<title>
Review - The Lord of the Rings: Fellowship of the Ring
</title>
</head>
<body>
<h1>Movie Review</h1>
<table border=”1” align=”right”>
<tr> <th colspan=”2”>Rating Scale</th> </tr>
<tr> <td>One *</td> <td>Not recommended</td> </tr>
<tr> <td>Two **</td> <td>Mediocre</td> </tr>
<tr> <td>Three ***</td> <td>Above Average</td> </tr>
<tr> <td>Four ****</td> <td>Highly Recommended</td></tr>
<tr> <td>Five *****</td> <td>A Must-See!</td> </tr>
</table>
<h2>
The Lord of the Rings:
<br>
Fellowship of the Ring
</h2>
<h3>Rating: Four ****</h3>
<p>
This movie perfectly captures the feelings of reading
<cite>The Lord of the Rings</cite> books by J.R.R. Tolkien
— large, impressive, fantastic, and mythic, but also
large, ponderous, slow, and meandering.
</p>
<p>
Now, I like the original books as much as any other
Science-fiction and fantasy fan, despite getting only
halfway through the second of three books before giving
up. Nevertheless, I gaped in awe at the majestic
landscapes of Middle Earth depicted on the big screen rather
than only in my imagination. I saw elves, hobbits, wizards,
dwarves, orcs, and even a few humans come to life, and it
all <em>felt right</em> — but it also felt very long,
nearly 3 hours in length, even with the plot pared
down for the movie.
Getting Started with CSS 33
2
continues
05 0672324091 ch02 6/13/02 10:39 AM Page 33
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
</p>
<p>
Some story points were inexplicably confusing; bit
characters wander off and onto the screen, and none ever
stop to really explain what the big deal is about the
ring. If I hadn’t read the first book already, I might
have been scratching my head in confusion. But
ultimately, <cite>Fellowship of the Ring</cite> is a treat
designed especially for anyone who loves Tolkien’s epic
work of mythic fantasy; it’s a faithful, if exhausting,
adaptation of this 20th-century classic.
</p>
<hr>
<address>
Reviewed by
<a href=”mailto:”>Kynn Bartlett</a>
</address>
</body>
</html>
As seen in the screenshot in Figure 2.3, this displays as a rather plain page without CSS.
This is our “before” picture.
34 Hour 2
FIGURE 2.3
Internet Explorer 5’s
default rendering of
basic-2.2.html.
LISTING 2.2 Continued
05 0672324091 ch02 12/3/02 12:14 PM Page 34
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Getting Started with CSS 35
2
Linked Style Sheets in HTML
To apply the style sheet to our HTML page, we’ll need to tell the browser which style
sheet to use. We do this by using the <link> element of HTML, and we’ll use the
basic-2.1.css file from Listing 2.1.
The
<link> tag can appear only within the <head> section of our HTML page. To link
the style sheet, I open the HTML file and add the following line (shown in bold):
<head>
<title>
Review - The Lord of the Rings: Fellowship of the Ring
</title>
<link type=”text/css” rel=”stylesheet” href=”basic-2.1.css”>
</head>
The effect of applying the style sheet can be seen in Figure 2.4; compare this with
Figure 2.1 to see the difference some styles make.
FIGURE 2.4
Styles change the
appearance of the
plain HTML page.
Adding More Styles
If we want to add more to our page, we can just fire up the text editor and change the
CSS file. Alternately, we could create a different style sheet and change the <link> tag’s
href attribute.
Listing 2.3 shows a longer style sheet, and Figure 2.4 is our “after” shot, applying the new
style sheet (which can be downloaded from
http://CSSin24hours/02/basic-2.3.css).
05 0672324091 ch02 12/3/02 12:14 PM Page 35
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
LISTING 2.3 More Styles to Make Our HTML Page Interesting
/* basic-2.3.css */
/* Written by Kynn Bartlett <> */
body { font-family: Arial;
color: navy;
background-color: white; }
h1, h2, h3, h4, h5, h6 { font-family: Verdana, sans-serif; }
h1 { color: maroon; }
h2 { color: red; }
h3 { color: green; }
p { color: black; }
th, td { font-size: smaller; }
th { color: navy;
font-family: Verdana, sans-serif; }
td { color: green;
font-family: Times, sans-serif; }
em { color: red; }
cite { color: teal; }
address { font-family: Verdana, sans-serif;
font-size: smaller; }
a { color: fuchsia; }
36 Hour 2
FIGURE 2.5
A few simple
CSS rules spice
up the appearance
of the page.
05 0672324091 ch02 12/3/02 12:14 PM Page 36
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Viewing Your Style Sheet
Once you’ve created a style sheet, you’ll want to take a look at it to ensure that it works.
Uneven browser support for CSS means that it’s important to check how it appears in
various browsers, as well as to make sure you got the syntax correct.
To view the style sheet, simply view the HTML file that links to your CSS file. Don’t try
viewing the CSS file directly; it will just look like source code in many browsers. The
way to know if it worked is to look at the HTML page that’s being styled.
Recommended Browsers
You’ll want to verify your style sheet in at least the major browsers because they repre-
sent the greatest number of users who may access your page. You’ll also want to test in
browsers that have good support for the CSS standard. Browsers can vary between oper-
ating systems; Internet Explorer on Microsoft Windows handles CSS quite differently
from Internet Explorer on a Macintosh.
Naturally, it’s difficult for one person to have access to every different browser combination
available, but the more you’re able to use, the better your results will be. I recommend a
standard testing suite consisting of four browsers:
•Internet Explorer (5.0, 5.5, or 6.0 on Windows; 5.0 or 5.1 on Macintosh)
• Netscape (4.7 or higher; Windows, Macintosh, or Linux)
• Mozilla (0.9 or higher; Windows, Macintosh, or Linux) or Opera (5.0 or 6.0;
Windows, Macintosh, or Linux)
•Lynx (2.7 or higher; Windows, Macintosh, or Linux)
These browsers represent a good cross-section for testing, and are generally widely avail-
able on most popular operating systems. In Hour 3 and Hour 18, “Web Design with
CSS,” you’ll learn more about testing strategies.
Summary
In this hour, you learned about using text editors and specialized software to create and
edit style sheets, which are just ordinary text files of CSS rules. You learned the general
structure of a CSS rule and its component parts, including the selector, the declaration,
the property name, and the property value. You learned how and why to include com-
ments in your CSS files. You got to see a few simple styles change an HTML page, set-
ting the text color, size, and font, and you learned how the HTML <link> tag associates
a style sheet with a Web page. Finally, you learned how to display your page in your
browser and see your CSS in action.
Getting Started with CSS 37
2
05 0672324091 ch02 6/13/02 10:40 AM Page 37
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Q&A
Q I’m not sure what the “RGB” values used for colors are. Can you explain?
A Sure! RGB triples are one of the most common ways to specify color on the Web,
in both HTML and CSS. RGB stands for Red-Green-Blue and is a standard way
for specifying a color as a composite of three values: the amount of red, the
amount of green, and the amount of blue. In HTML and CSS these are written in
hexadecimal numbers (base 16), which start with 0, go up to 9, and then continue
on to A, B, C, D, E, and F. If you don’t know how to use RGB hexadecimal values,
you can use the
rgb() function to specify colors, like this:
h1 { color: rgb(100%, 50%, 25%); }
Q Can I set the font-size to a specific value, such as 12 point?
A Yes, you can; 12 point is written as
12pt (no space). This is what’s known as an
absolute font size, though, and it can cause problems for users who need to adjust
their preferences to account for visual impairments. For now I recommend sticking
with the relative values given earlier in this hour, like larger and x-small,but if
you want you can read ahead to Hour 8 for more font size units.
Workshop
The workshop contains quiz questions and activities to help reinforce what you’ve
learned in this hour. If you get stuck, the answers to the quiz can be found after the
questions.
Quiz
1. What kind of software is needed to create a CSS file?
2. What is the name of the part of a CSS rule that goes within the curly braces?
(a.) The selector
(b.) The declaration
(c.) The property name
(d.) The property value
3. You want to make all of your HTML headings (
<h1>,and so on) blue and in Arial
font. What CSS rule(s) do you write?
38 Hour 2
05 0672324091 ch02 6/13/02 10:40 AM Page 38
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Answers
1. Because CSS files are just ordinary text files, anything that can create or edit text
files can make a style sheet. This includes text editors, style sheet editors, Web
development tools, and word processors. The important thing is to save the files as
plain text, usually with a .css file extension suffix.
2. The declaration, which consists of the one or more pairs of property names and
values, is the part of the CSS rule between curly braces.
3. Here’s the easiest way to make headings blue and Arial:
h1, h2, h3, h4, h5, h6
{
color: blue;
font-family: Arial;
}
You could also write this as several rules—as many as 12—but this combined form
is the easiest way to do it.
Activity: Create Your First Style Sheet
Learning by doing is the key to understanding Cascading Style Sheets, and building your
own style sheet is the first step in the process. Follow these instructions to create and test
your own CSS:
1. Select an HTML page to style. This could be one you’ve created before, a brand
new one, or perhaps the
basic-2.2.html file used earlier this hour.
2. Create a new CSS file using the text editor of your choice. Using the style proper-
ties you learned this hour, add style rules to apply to your HTML page. Change the
color of the text, the background color, the font sizes, and the text font. Save this
file with a
.css extension.
3. Use the
<link> tag in your HTML to associate the style sheet with the HTML
page. Be sure the HTML and CSS files are in the same directory, or else the
browser might not be able to find the CSS file. (You can use full URL paths if you
want, but for now, it’s easiest to have HTML and CSS in the same location.)
4. Open your page in your primary Web browser and view the results of your work.
You may want to go back and tweak the CSS to see what effect additional styles
have; go right ahead!
5. If you have any of the other recommended browsers, try the page with those. You
probably won’t see much difference because the CSS properties introduced are rel-
atively safe and reasonably well supported.
Getting Started with CSS 39
2
05 0672324091 ch02 6/13/02 10:40 AM Page 39
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
05 0672324091 ch02 6/13/02 10:40 AM Page 40
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
HOUR
3
Browser Support for CSS
To be able to master the full power of Cascading Style Sheets, you need to
understand the biggest issue related to using CSS—browser support. No
other Web-related technology has been more limited by poor browser
implementation than Cascading Style Sheets. However, the situation con-
tinues to improve, as recent browsers are getting closer and closer to full
support for CSS.
In this hour, you’ll learn
• What the browser problem is and why it’s a problem
•The general categories of browsers and how each type affects your
CSS Web designs
•The essential need for workarounds and how to measure the cost of
failure
•How the current browsers use Cascading Style Sheets
•How to read the Browser Support Report Card found in each subse-
quent hour of this book
06 0672324091 ch03 6/13/02 10:36 AM Page 41
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
The Browser Problem
A Web browser is the essential Internet access tool of the early twenty-first century.
Browsers are becoming indispensable to business, education, and personal communication.
They create a common platform upon which Web-based applications can be built, with an
HTML framework driving e-commerce, business-to-business transactions, Web-based
learning, and online communities. Hundreds of thousands of pages of new information are
added to the Web each day. Cascading Style Sheets play a crucial role in this adolescent
communications medium not only by providing a pleasant visual layer on the surface of
these Web applications, but also by potentially reshaping the entire user experience.
So what’s the problem? In short: Web browsers are terrible at CSS.
There are a variety of reasons for this. Some browsers, such as Netscape 3, were cre-
ated before the CSS specification was published. Other browsers are limited in what
they’re meant to do: Lynx is a text-only browser and doesn’t do CSS at all, whereas
WebTV terminals understand only a subset of CSS. Some browsers jumped the gun;
Microsoft is notorious for jumping the gun and using draft specifications of standards
in their browsers. And sadly, some browsers are just plain bad. They may seem to
function normally, but when it comes to consistent and standardized support for CSS,
they fall very short.
The good news is that the problem is being solved. Slowly but surely, each new major
browser release is better than the last, and you can get pretty decent, though not perfect,
CSS implementations from Mozilla, Netscape 6, Opera, and certain versions of Internet
Explorer.
How Browsers Deal with CSS
When a browser encounters anything—from CSS rules to HTML, JavaScript to Flash
multimedia—it has three choices as to what it can do. If the browser has been programmed
to understand the thing it has encountered, it will attempt to display it according to the
specification. If it has no idea what it has come across, it can ignore it. Both of these
options can be considered “doing the right thing.” Or, the browser can do the wrong thing.
It can get confused; it can display in some nonstandard way; it can crash. This third option
is the least desirable and is the primary root of our problem.
Cascading Style Sheets were designed from the start to degrade gracefully. This means
that if your CSS rules aren’t recognized for some reason, your page will still be usable
and the content accessible. Because we’ve separated presentation from content, our con-
tent should be able to stand on its own, albeit not as beautifully, once our presentation is
removed. At least, that’s the theory.
42 Hour 3
06 0672324091 ch03 6/13/02 10:36 AM Page 42
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
In practice it’s not nearly as easy as that. To be an effective CSS author, you’ll need to
know not only what works in any given browser—or in most or all of them—but also
what happens when it doesn’t work. Is it as simple as your style not being applied cor-
rectly and you losing a bit of decoration, or is it as serious as your entire layout being
disrupted and content being lost?
To understand how browsers deal with CSS, I’ve divided them up into four categories:
older browsers, which pre-date the CSS specification and thus ignore it completely; lim-
ited browsers, which don’t even attempt to support all of CSS; broken browsers, which try
to provide CSS functionality but fail horribly in some manner; and compliant browsers, of
which there are sadly few to none. Each category of browsers will treat Cascading Style
Sheets differently, and it’s important to understand what those differences are.
Older Browsers
Older browsers are those that existed before Cascading Style Sheets were even a glimmer
in the W3C’s collective eye. Netscape 3 is the classic example of an older browser, and it
does exactly what it’s supposed to do: it ignores CSS entirely. If you try to visit a Web
page styled with CSS, Netscape 3 won’t notice a single rule you’ve written. The style
sheet won’t even load.
This is actually ideal behavior for older browsers; with CSS designed for backwards
compatibility, most CSS-based Web sites should still work, although they may be some-
what boring in appearance. Because Netscape 3 is ignoring all CSS rules, we know
exactly what it will do with them; there’s no guesswork necessary on the part of the
author. You won’t have to do anything special to support these types of browsers, except
for testing your designs to see if they still function without CSS.
Browser Support for CSS 43
3
You can simulate an older browser by configuring a newer browser to delib-
erately ignore CSS in the preferences settings for each browser. By doing so,
you can check to see if your designs work in browsers that don’t understand
CSS; a properly designed style sheet should be perfectly understandable in
an ancient browser, such as Netscape 3.
Limited Browsers
Limited browsers are those that are not intended to be full-fledged general-use multimedia
Web browsers; instead, they serve a very specific function and thus don’t have a need for
all the capabilities found in CSS.
A limited browser is troubling because it supports only a subset of Cascading Style
Sheets—and not one that’s broken cleanly along the lines of the CSS Level 1 and CSS
06 0672324091 ch03 6/13/02 10:36 AM Page 43
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Level 2 specifications. Microsoft’s WebTV is an example of this type of browser; it
supports only a small number of CSS properties, and not all of them. Another example
is EmacSpeak, a screenreader for the visually impaired that supports aural CSS but not
most visual formatting properties.
Supporting these browsers can be difficult, but they tend to be uncommon in practice, and
usually the subsets of CSS they support are intelligently chosen, such as how EmacSpeak
doesn’t support visual properties but has a good reason for not doing so. Testing your
design in an older browser (or one with CSS purposely disabled) is usually enough to
cover limited browsers, although if you’re designing specifically for audiences using these
types of browsers, you may want to have a copy for your own testing purposes.
Broken Browsers
The worst kind of browser is one that is simply broken when it comes to CSS, despite
whatever claims the provider makes to standards compliance. A broken browser is one
that, when given perfectly legitimate Cascading Style Sheets rules, doesn’t present a Web
surfer with anything she can use, but instead displays a mishmash of styles where infor-
mation gets lost. The difference between an older browser and a broken browser is that
older browsers don’t try to display CSS, and broken browsers try and fail horribly.
Internet Explorer 3 was the first browser to implement any CSS, but it did an overall bad
job at it, based in part on the fact that they coded to a specification that was still being
written at the time. When the final version of CSS Level 1 came out, it was quite differ-
ent from Internet Explorer 3’s attempt to implement CSS support.
Fortunately, Internet Explorer 3 has almost passed into memory, replaced by newer ver-
sions of Internet Explorer that are closer to the CSS specification, meaning that the buggy
CSS implementation in Internet Explorer 3 really isn’t a factor in current CSS usage.
The current front-runner in broken browsers—causing the most headaches for CSS
developers around the world—is Netscape 4. Unlike Netscape 3, Netscape 4 does indeed
attempt to support Cascading Style Sheets but fails miserably in many ways. For exam-
ple, Netscape 4 doesn’t understand many of the key CSS properties needed to lay out a
page, set font styles, or align text.
To account for the broken browsers out there, it’s necessary to understand how they’re
broken and what happens when you give each browser some CSS rules that it doesn’t
understand. In some cases, the broken browser will just ignore your CSS, as is the case
with a limited or older browser; in others, it may do something horribly wrong. In this
book we’ll point out those problems and help you design CSS that will work on as wide
a selection of browsers as possible.
44 Hour 3
06 0672324091 ch03 6/13/02 10:36 AM Page 44
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Compliant Browsers
Working with a completely CSS-compliant browser is a joy—or it would be, if such a
creature existed. At the moment there are no browsers that completely support all of the
Cascading Style Sheets Level 2 specification, and only a handful that can legitimately
claim full CSS Level One support.
Luckily, there’s plenty of motion in the direction of full support, which means things are
only getting better with each released browser version. Browsers that are very close to
being compliant with the standard include—starting with the most compliant—Mozilla,
Netscape 6, Opera 5 and 6, and recent versions of Internet Explorer, especially for
Macintosh.
Coding CSS for a compliant browser is simply a matter of following the standard and
reaping the benefit of your work. Unfortunately, this idyllic vision is still not yet a real-
ity, as near-compliant browsers constitute only a small fraction of the browsers in use.
For the foreseeable future, you’ll need to keep in mind the needs of users without fully
CSS-compliant browsers, and that means using workarounds when necessary.
The Importance of Workarounds
Because there are so many broken browsers out there, it’s often necessary to use a work-
around to effect the same functionality you would get on a compliant browser. A
workaround is a hack—a nonstandard way of getting a certain result that bends and
tweaks the syntax of CSS or HTML in order to produce the type of style effects you’re
trying to achieve.
A good workaround is one that stays within the published standards—CSS and HTML
primarily—so that it doesn’t break on browsers that are compliant with the standards. A
partial workaround is one that gives a similar effect but doesn’t fully measure up to the
kind of styling you could do if the browser were standards-compliant.
Browser Support for CSS 45
3
For some browser limitations and bugs, there are simply no viable workarounds that
give the same functionality; in those cases you will have to make a difficult choice—
include the CSS despite browser limitations or leave it out entirely. The basis for this
decision is the cost of failure.
Workarounds in This Book
Whenever possible, I’ve identified useful workarounds to compensate for
browser limitations. These are formatted like this, as a tip, with the titles of
the affected browsers in the heading of the tip.
06 0672324091 ch03 6/13/02 10:36 AM Page 45
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
The Cost of Failure
The cost of failure is simply an understanding of what will happen if you use specific
CSS rules or properties that aren’t understood by the browser.
In some cases, you’ll want to use CSS properties that aren’t well supported; you may fig-
ure that the cost of failure is low enough that you don’t mind some users missing out on
a special styling if it improves the site for those users with more advanced browsers. In
other cases, you may decide you can’t take that chance, and you’ll have to make a choice
whether to support the broken browsers with workarounds or ignore that audience.
For example, consider a CSS rule that makes the first letter of each section stand out
large in a stylized font. This may just be simple decoration, and if the font is normal
sized in some browsers, so be it; it may not affect at all the way your page functions.
Browser Compatibility Charts
A browser compatibility chart is an invaluable resource for anyone doing serious CSS
work. What is it? A compatibility chart lists every CSS property in a matrix, cross-
referenced with a number of different browsers (including various version numbers and
platforms). For example, if you want to know if the Netscape 4 browser supports the
color property, you can consult a compatibility chart. For each property you look up,
you’ll see whether or not it’s supported by the browser, and if there are any special
notes or known bugs in the implementation.
The best-known CSS browser compatibility chart is maintained by Eric Meyer as part
of the WebReview site and is located at
I highly
recommend bookmarking that site and referring to it as you test your CSS-based
designs. Another good browser compatibility chart is from WestCiv, the makers of the
Style Master CSS editor; their charts are at />academy/browser_support.
In this book, I take a complementary approach to reporting compatibility; instead of rating
the browsers, I give each CSS feature or property a grade at the end of each hour. This
grade reflects not only the browser support but also the cost of failure in nonsupporting
browsers. This will let you make an informed choice when creating your cross-browser
CSS, and avoid those properties or features that are not safe yet for general use.
Web Standards and You
As you know, CSS is defined by the Cascading Style Sheets Level 1 and Level 2 recom-
mendations from the World Wide Web Consortium. These recommendations function as
standards for the CSS language.
46 Hour 3
06 0672324091 ch03 6/13/02 10:36 AM Page 46
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Standards are a good thing for developers; the more the browsers support the standards,
the easier it is for us to create expressive and attractive designs in CSS and know they’ll
work reliably. Increased support from standards, the browser makers, the Web developer
community, and the Web software manufacturers will only make our jobs easier.
One group of Web designers decided to take their support for standards public and
founded the Web Standards Project to encourage browser makers to adhere closely to
the CSS recommendations and other Web standards. In addition to their advocacy
work, the Web Standards Project site contains useful FAQs and links on standards sup-
port. Their URL is
/>CSS Support in Current Browsers
The rest of this hour represents a snapshot of the browser world as of the first half of 2002.
Newer versions of these browsers may be out by the time you read this and could offer even
greater support for the CSS standards, so be sure to check the Web sites for the latest versions.
For the major browser types I’ve provided screen shots of the browsers in action, dis-
playing a page with some high-powered CSS—part of the css/edge, a CSS site by Eric
Meyer that pushes the boundaries of what you can do with standards-compliant CSS.
The URL for each of these examples is the css/edge spiral, from
/>eric/css/edge/complexspiral/demo.html. Figure 3.1 illustrates how the spiral is supposed
to appear, as shown by Netscape 6.
Browser Support for CSS 47
3
FIGURE 3.1
The css/edge spiral
demo as it should look
(Netscape 6).
06 0672324091 ch03 6/13/02 10:36 AM Page 47
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Internet Explorer
Microsoft’s Internet Explorer has been declared by many to be the winner of the 1990s
browser wars. Internet Explorer 3 had the first support for Cascading Style Sheets, but
unfortunately it was quite disastrous and unusable. Subsequent versions have improved a lot.
Internet Explorer is available on two primary platforms—Windows and Macintosh. (A
“pocket” version exists for Pocket PCs running Windows CE.) An important point to
keep in mind is that the Windows and Macintosh versions of Internet Explorer are effec-
tively completely different browsers. They share some common functionality, but the
core code for each is different, and they have vastly divergent support for Cascading
Style Sheets and other Web standards.
IE 5, 5.5, and 6 for Windows
CSS support in Internet Explorer 5 for Windows is what one would call “almost compli-
ant and just somewhat broken,” and each subsequent version gets one step better. Internet
Explorer 6 implements a standards compatibility mode that pretty much moves it into the
category of compliant browsers.
48 Hour 3
You can download a copy of Internet Explorer for Windows from the
Microsoft Web site at />The css/edge spiral as displayed by Internet Explorer 6 for Windows is shown in Figure 3.2.
FIGURE 3.2
Internet Explorer 6
(Windows) displays
the css/edge spiral.
06 0672324091 ch03 6/13/02 10:36 AM Page 48
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
IE 5 and 5.1 for Macintosh
As mentioned before, Internet Explorer for Macintosh should be considered a completely
different species of browser than its Windows cousin. Internet Explorer 5 for Mac, at the
time it was first released, was the most standards-compliant browser available and was
far ahead of the Windows counterpart. Version 5.1 continued this strong support for CSS
and other standards.
Browser Support for CSS 49
3
The Web site for Internet Explorer for Mac is />mac/products/ie/
.
You can see the css/edge spiral displayed as it’s meant be shown in Figure 3.3.
FIGURE 3.3
The css/edge spiral in
Internet Explorer 5.1
for Macintosh.
Older Versions of Internet Explorer
Internet Explorer 3 and 4—on either platform—have had serious problems with CSS and
fall into the category of broken browsers. Users with these older versions should be
encouraged to upgrade or to possibly just disable CSS.
06 0672324091 ch03 6/13/02 10:36 AM Page 49
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Netscape
Like the brand name Internet Explorer, the Netscape brand name also applies to two
vastly different browsers with the same name. Netscape 4 is the earlier version and is
quite buggy, especially when it comes to browser support, whereas Netscape 6 is quite
possibly one of the most CSS-compliant browsers available.
Netscape 6 and Mozilla
It’s important to realize where Netscape 6 came from. In the middle of the fierce browser
competition of the late 1990s, Netscape proposed a daring plan. The core browser engine
code was made publicly available as part of an open source project—one in which any-
one is welcome to volunteer and contribute programming code to the collective, public
code base. This was known as the Mozilla project.
Admittedly, the results have been slow in coming—Netscape even had to skip browser
version 5 entirely to maintain the illusion of keeping up—but there have also been
impressive results. Netscape 6, based on the Mozilla project’s work, is a browser that is
very good at Cascading Style Sheets as well as one that offers excellent support for
HTML standards.
Mozilla is available on a multitude of systems, including Windows, Macintosh, Linux,
and others. As it is a work in progress, there are daily developer builds available for test-
ing as well as regular milestone releases.
50 Hour 3
You can download the most recent version of Mozilla from
/>Netscape 6.2.1 is the most current version of Netscape 6 as this book is being written.
You’ve already seen an example of Netscape 6 displaying the css/edge spiral in Figure 3.1.
The URL for downloading Netscape is />computing/download/
.
Netscape 4
Netscape 4.79 is the most recent version of Netscape 4, but as noted before, Netscape 4
has very poor support for Web standards, including CSS. However, as a CSS developer
you’ll probably want to have a version of Netscape 4 available for testing.
06 0672324091 ch03 6/13/02 10:36 AM Page 50
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Figure 3.4 shows Netscape 4’s attempts to display the css/edge spiral.
Browser Support for CSS 51
3
You can download a version of Netscape 4 from />download/
.
FIGURE 3.4
As you can see,
Netscape 4 can’t
quite handle the
complex CSS of the
css/edge spiral.
Older Versions of Netscape
Some older versions of Netscape 4 were even worse at CSS; for example, version 4.02
would routinely crash if you tried to apply certain styles to a table cell. Netscape 3 is
useful for testing, however, as it is an excellent example of an older browser that com-
pletely ignores CSS.
Older versions of Netscape can be found at />download/archive.html
.
Opera
Opera is the perpetual third-runner of browsers; fast and small and standards-compliant, it
still doesn’t enjoy the same popularity as the big two browser names. The Chief Technology
06 0672324091 ch03 6/13/02 10:36 AM Page 51
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Officer at Opera, Håkon Wium Lie, was one of the principal authors of the CSS Level 1 and
Level 2 recommendations, so you know they know their stuff! Since version 3, Opera has
consistently had great CSS support, improving incrementally with each release.
Opera 6
Opera 6 is the current version available for Windows, and I highly recommend getting a
copy if you’re a Windows user. In addition to the CSS support, it also features one-click
buttons to turn off and on CSS rendering, user style sheets, and more, which combine to
make this an excellent testing tool.
52 Hour 3
You can download Opera 6 from />The css/edge spiral is shown in Figure 3.5 on Opera 6.
FIGURE 3.5
Opera 6 is up to the
task of displaying the
css/edge spiral.
Opera 5
Opera 5 is the most recent version for Macintosh, Linux, and other platforms. Unlike
Internet Explorer, Opera is consistent across various platforms and functions much the
same no matter what it’s running on, especially when it comes to rendering CSS.
06 0672324091 ch03 6/13/02 10:36 AM Page 52
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Browser Support for CSS 53
3
The Opera 5 download page is />Other Browsers
The world of browsers definitely doesn’t end with just Internet Explorer and Netscape,
and not even with Opera. There are a number of other browsers that understand CSS to
varying degrees, including iCab for Mac, WebTV on set-top boxes, Konqueror for Linux,
and Lynx for nearly any system.
iCab
iCab is a Macintosh Web browser made by a company in Germany; you can run iCab in
German or in English. iCab has limited CSS support, but they do take standards seri-
ously; the iCab browser displays a sad face when it reaches a page with invalid HTML
and a happy face when the page conforms to the HTML standards. Figure 3.6 shows
iCab’s attempt to display the css/edge spiral.
The iCab Web site is />FIGURE 3.6
iCab makes an
attempt to display
the css/edge spiral.
06 0672324091 ch03 6/13/02 10:36 AM Page 53
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
WebTV
The set-top WebTV boxes were an early attempt to make Internet appliances—devices
that make Web access as easy as using your microwave. They’re interesting to us as CSS
developers because they supported a limited subset of CSS, mainly for simplicity’s sake,
but also because some properties (such as fonts) didn’t make sense based on the type of
browser built into a WebTV. A WebTV emulator is available for Windows and Macintosh
and was used to view the css/edge spiral, as seen in Figure 3.7.
54 Hour 3
You can download the WebTV emulator from
/>FIGURE 3.7
WebTV has limited
CSS support, and so it
can’t quite handle the
css/edge spiral.
KDE Konqueror
Konqueror is part of the K Desktop Environment, an open source project creating soft-
ware for the Linux operating system. Konqueror functions as a Web browser (among
other functions) and has generally good support for CSS.
You can learn more about Konqueror at />06 0672324091 ch03 6/13/02 10:36 AM Page 54
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
Lynx
The Lynx browser is one of the oldest browsers around; it’s entirely text based. Lynx
doesn’t do JavaScript, doesn’t do Java, doesn’t do graphics, doesn’t do sound, doesn’t do
Flash, and doesn’t really do tables or frames particularly well (although those latter two
it can deal with okay).
What about CSS? Lynx doesn’t understand CSS at all. As such, it’s a perfect example of
the older browser category discussed earlier in this hour. Lynx is a good testing tool for
CSS development because it lets you see what your Web design will look like if style
sheets are turned off. Lynx is also a good approximation (although not an exact one) for
how people with visual disabilities access the Web using screenreaders.
Browser Support for CSS 55
3
FIGURE 3.8
Konqueror takes
the css/edge spiral
challenge.
Lynx is available for Windows, Mac, Linux, and a number of other operating
systems. You can download a copy of Lynx from />06 0672324091 ch03 6/13/02 10:36 AM Page 55
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.
So how does Lynx handle the css/edge spiral? As you can see in Figure 3.9, all of the
formatting and images are completely gone, but the page content is still understandable
and usable. This is how CSS is backwards compatible; older browsers can still access
and use the content even if the styling is lost.
56 Hour 3
FIGURE 3.9
Lynx doesn’t display
the css/edge spiral
styles at all.
Summary
Browser support is the key issue to understanding how to use Cascading Style Sheets
effectively. Older browsers ignore CSS, compliant browsers support CSS, and other
browsers either provide limited or broken support for the standards. Knowing how to
deal with the different types of browsers makes your style sheets more effective across a
variety of platforms and browser versions.
Internet Explorer for Windows version 6, Internet Explorer for Macintosh version 5,
Netscape 6, Opera for Windows 6, and Opera for Macintosh 5 are the latest available
browser versions at the time of writing, and they all have impressive support for CSS
standards that continues to increase with each new release. Other browsers, such as iCab,
WebTV, Konqueror, and Lynx, offer varying support for the CSS specifications.
06 0672324091 ch03 6/13/02 10:36 AM Page 56
Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.