valuesA glance at any of the properties sections of this guide will tell you that different properties can have different kinds of value. You probably don't really need to know all of the following, but we include it for completeness. You might like to treat it as a reference, or read through it now to get an understanding of the basic issues, then refer for more detail when you need to. The major kinds of value are: Any given property will be ale to take some appropriate subset of the values described below. Sometimes they will not be able to take all aspects of a given type of value, for example, not all properties that can take length values can take negative as well as positive length values. Note that any property can also take the value Length valuesLength values can be positive or negative, have a numerical value, and must be followed by a unit of measurement. Note that while length values can be either positive or negative, several properties cannot have negative length units. There are two basic kinds of length unit, relative and absolute. As a rule of thumb, absolute units should be used only when the physical characteristics of the output device are known. This means that units like points and pixels should be avoided for monitors (because we cannot be sure of the logical resolution (Macintoshes default to 72 dpi, Windows to 96 dpi, or screen sizes). We discuss some implications of this for design and implementation of web pages in our real world CSS section of the guide. As a starting point though, you should try to use relative length values wherever it is at all possible. The units of measurement are
It is worth learning a little bit about each of these, as there are benefits and pitfalls in the use of each. The links section of the House of Style has pointers to a number of interesting discussions about the use of different units. A very thorough and useful coverage of these issues is given by Tod Fahrner. This is a must read for those who want to use style sheets correctly. We also discuss the issue of the appropriate use of various units in more detail in our real world CSS section. Browser supportDetailed browser support information for this feature can be found in the full version of the Westciv CSS Guide, or in our CSS Browser Support Table. Percentage valuesInstead of using a unit of measurement many properties can also take percentage values. You'll remember that an element is contained within another element (for example, a For example, specifying a Percentages are very valuable with positioning, as when a user resizes their window, the same basic layout can be achieved for the new window size. The form of a percentage unit is a positive or negative sign (no sign means positive units), followed by a number, followed by the percentage sign: %. For example -25%, +15% or 15%. Browser supportSee the Westciv CSS Guide, or our CSS Browser Support Table. Color valuesBackgrounds, text and borders can be assigned colors. Color values can be specified in one of three ways:
Color keywordsThere are 16 color keywords, taken from the windows color palette. These keywords are
There is no exactly defined rgb value for these keywords, it is up to the browser developers to decide what they might mean. Generally all browsers render the same color keyword as the same color. CSS2 introduced 26 keywords for system colors. These specify colors that the user interfaces of various operating systems such as the MacOS or Windows 98 use for drawing objects. These colors are
Hexadecimal RGB colorsFor whatever reason, the original web palette (now sRGB) used hexadecimal numbers (base 16 not base 10 numbers, and if you don't know, don't worry about it) for specifying colors. In short, these RGB colors are specified as a combination of Red Green and Blue. There can be 256 different hues of each color, (from 00 to ff - that's 0 to 255 in human speak). CSS allows you to specify colors using this method, in the following forms: 1) The 2) The RGB colorsBecause humans are generally more comfortable counting to base 10 than base 16, CSS lets us use decimal rgb values. The color gamut (the total range of colors) is exactly the same, we are just specifying it in a different way. There are two forms of this value, a numerical and a percentage form. They are interchangeable. 1) The numerical form of the color value is the following 2) The percentage form of the rgb color value replaces the values in the range from 0 to 255 with a percentage value from 0 to 100%. For example, the above value would be written To recap, the following values are all equivalent: green #00ff00 #0f0 rgb(0, 255, 0) rgb(0%, 100%, 0%) Browser supportSee the Westciv CSS Guide, or our CSS Browser Support Table. URL valuesBackground images and list item images are specified with a URL. This url can be either absolute (that is, the full URL, e.g URLs have a straightforward form: url(the url) Absolute URLs are written like this: Browser supportSee the Westciv CSS Guide, or our CSS Browser Support Table. Keyword valuesMany different properties can take keyword values. A keyword value is simply a single word that is translated into a numerical value by a browser. The keywords available for a specific property will be appropriate to that particular property. Some keyword values are relative (to the parent element). For example
Shape valuesThe uncommon shape value (it is only used currently for the clip property, introduced as part of CSS2) defines a shape. At present, there is simply a rectangle shape. The form of the rectangle shape is: rect( top left bottom right ) Each of top, left, bottom and right can be either a length value, or the keyword This value is probably going to be redefined because it doesn't follow the same basic model as the box model of CSS1, where element positions are defined by a top and left corner, along with a width and a height. In addition, further shapes are planned. next: advanced CSS |