Section 2.1. Property Value Types


2.1. Property Value Types

Many properties share similar data requirements. For the sake of brevity in the reference listings, this section describes a few common property value types in more detail than is possible within the listings. Whenever you see one of these property value types associated with a property, consult this section for a description of the type.

2.1.1. Length

A length value defines a linear measure of document real estate. The unit of measurement can be any applicable unit that helps identify a position or space on the screen. For properties that reflect HTML attributes, length units are uniformly pixels, but in other content, such as that specified in Cascading Style Sheets (see Chapter 4), measurements can be in inches, picas, ems, or other relevant units. A single numeric value may represent a length when it defines the offset from an edge of an element. For example, a coordinate point (10,20) consists of two length values, denoting pixel measurements from the left and top edges of an element, respectively.

2.1.2. Identifier

An identifier is a name that adheres to some strict syntactical rules. Most important is that an identifier is one word with no whitespace allowed. If you need to use multiple words to describe an item, you can use the intercapitalized format (in which internal letters are capitalized, also known as lowerCamelCase) or an underscore character between the words. Most punctuation symbols are not permitted, but all numerals and alphabetical characters are. Scripting languages do not allow the use of a numeral for the first character of an identifier.

2.1.3. URI and URL

The term Universal Resource Identifier (URI) is a broad term for an address of content on the Web (while an Internationalized Resource IdentifierIRIis an address that can include Unicode characters to accommodate non-ASCII characters). A Universal Resource Locator (URL) is a type of URI. For most web authoring, you can think of them as one and the same, since most web browsers restrict their focus to URLs. A URL may be complete (including the protocol, host, domain, and the rest) or may be relative to the URL of the current document. In the latter case, this means the URL may consist of an anchor, file, or pathname. An object property that refers to a URL requires that the text of the URL be represented as a quoted string.

2.1.4. Language Code

There is an extensive list of standard codes that identify the spoken and written languages of the world. A language code always contains a primary language code, such as "en" for English or "zh" for Chinese. Common two-letter primary codes are cataloged in ISO 639. An optional subcode (separated from the primary code by a hyphen) may be used to identify a specific implementation of the primary language, usually according to usage within a specific country. Therefore, while "en" means all of English, "en-US" means a U.S.-specific version of English. The browser must support a particular language code for its meaning to be of any value to an element attribute.

2.1.5. Colors

A color value can be assigned either via a hexadecimal triplet or with a plain-language equivalent. A hexadecimal triplet consists of three pairs of hexadecimal (base 16) numbers that range between the values 00 and FF, corresponding to the red, green, and blue components of the color. The three pairs of numbers are bunched together and preceded by a pound sign (#) in the form #rrggbb. Therefore, the reddest of reds has all red (FF) and none (00) of the other two colors: #FF0000; pure blue is #0000FF. The letters A tHRough F can also be lowercase. For values that apply to style sheet properties, a color may also be represented in the RGB (red-green-blue) format consistent with CSS conventions (see Chapter 4).

These numbering schemes obviously lead to a potentially huge number of combinations (over 16 million). In the early days of the Web, typical PC display settings (throttled by limitations in processing power and memory) limited output to 256 colors, meaning that subtle differences among the 16 million potential colors were lost on visitors who had those settings. As a result, web content authors commonly used what became known as a web-safe palette consisting of 216 distinguishable colors. Although today's computers have sufficient processing power and memory to accommodate millions of colors with ease, some page designers continue to adhere to the more limited palette to ensure backward compatibility. A fine online reference of colors that work well on all browsers and PC color display settings can be found at http://www.lynda.com/hex.asp.

The HTML recommendation also specifies a basic library of 16 colors that can be assigned by plain-language names. Note that the color names are case-insensitive. The names and their equivalent hexadecimal triplets are as follows:

Black
#000000
Maroon
#800000
Green
#008000
Navy
#000080
Silver
#C0C0C0
Red
#FF0000
Lime
#00FF00
Blue
#0000FF
Gray
#808080
Purple
#800080
Olive
#808000
Teal
#008080
White
#FFFFFF
Fuchsia
#FF00FF
Yellow
#FFFF00
Aqua
#00FFFF

In other words, the attribute settings bgcolor="Aqua" and bgcolor="#00FFFF" yield the same results.

Many years ago, Netscape deployed a much longer list of plain-language color equivalents, originally adopted from the X Window System palette known as X11 color names. These are detailed in Appendix A, and are recognized by recent versions of mainstream browsers.




Dynamic HTML. The Definitive Reference
Dynamic HTML: The Definitive Reference
ISBN: 0596527403
EAN: 2147483647
Year: 2004
Pages: 120
Authors: Danny Goodman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net