Chapter 45. Changing the Look of a Text Element


In CSS, the simplest style selector is just the name of an HTML tag. The style definition for this simple selector determines how the browser displays the element wherever it appears on the page:

 h1 {   font-family: Arial;   font-weight: bold; } p {   font-family: Verdana; } 

So it goes for redefining the generic appearance of HTML text tags. But CSS allows you to choose much more specific selectors for entire sequences of tags to get precisely the typographical effect you have in mind, as Table 45.1 shows.

Table 45.1. CSS Selectors for HTML Tags

SELECTOR

DESCRIPTION

EXAMPLE SYNTAX

EXAMPLE DESCRIPTION

Simple

All HTML tags of a type

p

All paragraphs

Contextual

All HTML tags of a type that are somewhere within a tag of another type

table em

All emphasis tags that appear somewhere inside a table

Child[*]

All HTML tags of a type that have as their immediate parent a tag of another type

td > p

All paragraphs that have table cells as their immediate parents

Sibling[*]

All HTML tags of a type that follow a tag of another type but aren't the children of this other tag

h1 + p

All paragraphs that immediately follow first-level heads


[*] These selectors don't always work very well in IE.



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

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