SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 57 | Next

Craig Grannell

"The Essential Guide to CSS and HTML Web Design"

This makes sense??”you may add
property/value pairs to a rule at a later date, and if the semicolon is already there, you
don??™t have to remember to add it.
If we want to amend our paragraph declaration and define paragraphs as bold, we can do
so like this:
p {
color: blue;
font-weight:bold;
}
Types of CSS selectors
In the previous example, the most basic style of selector was used: an element selector.
This defines the visual appearance of the relevant HTML tag. In the sections that follow,
we??™ll examine some other regularly used (and well-supported) CSS selectors: class, ID,
grouped, and contextual.
Class selectors
In some cases, you may wish to modify an element or a group of elements. For instance,
you may wish for your general website text to be blue, as in the examples so far, but some
portions of it to be red. The simplest way of doing this is by using a class selector.
In CSS, a class selector??™s name is prefixed by a period (.), like this:
.warningText {
color: red;
}
This style is applied to HTML elements in any web page the style sheet is attached to using
the class attribute, as follows:

This heading is red.


This text is red.


This is a paragraph, and this text is
?‚ red
.


You don??™t have to lay out CSS rules as done in this section; rather, you can add rules
as one long string. However, the formatting shown here is more readable in print.


Pages:
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6