Book HomeCascading Style Sheets: The Definitive GuideSearch this book Thursday 24th of April 2014 08:28:45 PM

Appendix A. CSS Resources

Contents:

General Information
Tips, Pointers, and Other Practical Advice
Online Communities
Bug Reporting

There are a number of very good CSS-related resources available on the Web. Here are some of them.

A.1. General Information

These resources provide a good overview of what's happening in the world of CSS or otherwise provide you with a broad look at CSS.

A.1.1. CSS Recommendations

http://www.w3.org/TR/REC-CSS1

http://www.w3.org/TR/REC-CSS2

When all else fails, you can always use the source, Luke. The specifications contain, albeit in a somewhat terse and not always easily decipherable form, the complete description of how conforming user agents should handle CSS. They also contain a complete CSS parsing grammar and forward-compatible parsing rules, both of which are invaluable to the people who write user agents but of minimal interest to almost everyone else.

A.1.2. W3C CSS Activity Page

http://www.w3.org/Style/CSS

This is, officially speaking, the online center of the CSS universe. There are links to the CSS Recommendations, to new ideas under consideration, and to other sites about CSS. There are links to historical style sheet proposals, to information about current usage and implementations of CSS, and more. There are also lists of books about CSS, news of new CSS tools, and many other useful bits of information.

A.1.3. W3C CSS Test Suite

http://www.w3.org/Style/CSS/Test/

This presents a fairly complete set of pages designed to test any CSS implementation. Each page of the suite tests various aspects of CSS properties, one property per page. The tests were largely developed by the author of this book, Håkon Lie (Opera Software), and Tim Boland (NIST), with many contributions from the CSS community and even the browser vendors themselves. If you're wondering how good your browser is at handling CSS1, this is the place to find out. background-repeat: repeat;}

Figure 6-28

Figure 6-28. Tiling the background image in CSS

I've left out a background color in order to keep the ruleshort, but remember to include a background color any time you have abackground image. And, of course, the effect shown in Figure 6-28 would have been the same if we'd leftout the background-repeat property altogether,since repeat is its default value.

Let's assume, though, that we just want images down the leftside of the document. Instead of having to create a special image As of this writing, the Test Suite covers only CSS1, but a CSS2 Test Suite is expected in the near future.

A.1.4. Error Checkers

You can save a lot of time and effort simply by running your CSS through a validity checker. This is particularly recommended if you're thinking about asking for help online, because if your CSS contains errors, the first thing the experts will tell you to do is to use a validator. May as well get into the practice first.

A.1.4.1. W3C CSS Validator

http://jigsaw.w3.org/css-validator/

If you're having trouble getting your style sheets to work, it might be the result of a typographical error, or some other basic error that is difficult to diagnose. You could spend a long time combing through your styles, exhaustively checking each rule for correctness -- and that's a good exercise, of course -- but you could also have a program do it for you, and simply tell you if it found any errors. The W3C CSS Validator will do exactly that. You can supply it with the URL of a style sheet or document containing styles, or simply paste a block of styles into an input field, and let the validator tell you if your problems are the result of a misspelled color name (or something similar). The chief drawback, for most people, is the technical nature of its reporting. Unless you're already familiar with HTML and CSS, the results you get back may be somewhat confusing.

A.1.4.2. WDG CSScheck

http://www.htmlhelp.com/tools/csscheck/

Similar in nature to the W3C's validator, CSScheck offers much friendlier error messages, which makes it more useful to the beginning author. In addition to indicating the severity of the error with whimsical icons (American-style traffic signals, at last check), CSScheck provides a message detailing each problem, as well as the reason it is a problem. It is possible to learn a great deal about good document authoring practices simply by running a few style sheets through CSScheck and carefully reading its responses.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.

combined in the next chapter, but for now, let's just accept that they're combined. For example:

<LINK REL="stylesheet" TYPE="text/css" HREF="sheet-a.css">
<LINK REL="stylesheet" TYPE="text/css" HREF="sheet-b.css">
<P CLASS="a1">This paragraph will be gray only if styles from the
stylesheet 'sheet-a.css' are applied.</P>
<P CLASS="b1">This paragraph will be gray only if styles from the
stylesheet 'sheet-b.css' are applied.</P>
Figure 1-3

Figure 1-3. Combining linked style sheets

H1 {border-bottom: thick solid gray;}

This will apply the values to the bottom border alone, as shown in Figure 7-45, leaving the others to their defaults. Since the default border style is none, no borders appear on the other three sides of the element.

As you can see, the order of the actual values doesn't really matter. The following three rules will yield exactly the same border, as illustrated in Figure 7-47:a lowercase letter in the source. This may remind you rather strongly of text-transform: uppercase, with the only real difference that here, the uppercase letters are of different sizes. That's true, but the reason that small-caps is declared using a font property is that some fonts have a specific small-caps face. Thus, a font property is used to select that face.

What happens if no such face exists? There are two options provided in the specification. The first is for the user agent to create a

Figure 4-39

Figure 4-39. Vertical alignment with percentages

However, it's important to realize that the vertically alignedtext is not part of another line. It just appears that way when thereisn't any other text around. Consider Figure 4-40, in which some vertically aligned text appearsin the middle of a paragraph.

Figure 4-40

Figure 4-40. Percentage alignments can affect the height of a line

Of course, this sort of thing can lead to some fun visual effects, aswe see in Figure 4-41: