22.04.2013 Views

HTML, XHTML & CSS

HTML, XHTML & CSS

HTML, XHTML & CSS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

34<br />

Part III: Taking Precise Control Over Web Pages and Styles<br />

✓ ex: A value that is relative to the x-height of the current font. An x-height<br />

is the equivalent of the height of the lowercase character of a font, such<br />

as 1.5ex.<br />

✓ em: A value that is relative to the current font size, such as 2em. For any<br />

given typeface, 1 em is equivalent to its point size. (Thus, a 16pt font has<br />

an em size of 16pt: Get it?)<br />

In fact, both 1em and 100% equal the current size.<br />

Be careful when using these values; certain properties support only some<br />

measurement values — length values, say, but not relative values. Don’t let<br />

this jargon scare you. Just define the size in a value you’re familiar with. If<br />

that doesn’t work, try something else.<br />

<strong>CSS</strong> Structure and Syntax<br />

A style sheet is made of style rules. Each style rule has two parts:<br />

✓ Selector: Specifies the markup element to which style rules apply<br />

✓ Declaration: Specifies how content described by the markup looks<br />

You use a set of punctuation marks and special characters to define a style<br />

rule. The syntax for a style rule always follows this pattern:<br />

selector {declaration;}<br />

A semicolon always follows each declaration to make it easier for computers<br />

to distinguish them. A single selector can include one or more declarations,<br />

as we explain later in this chapter. Furthermore, each declaration breaks<br />

down into two sub-items:<br />

✓ Properties are aspects of how the computer displays text and graphics<br />

(for example, font size or background color).<br />

✓ Values provide data to specify how you want text and images to look on<br />

your page (for example, a 24pt font size or a yellow background).<br />

You separate the property from the value in a declaration with a colon.<br />

Each declaration ends with a semicolon.<br />

selector {property: value;}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!