Приглашаем посетить
Хомяков (homyakov.lit-info.ru)

Combining Selectors

Previous Page
Table of Contents
Next Page

Combining Selectors

When several selectors share the same declarations, they may be grouped together to prevent the need to write the same rule more than once. Each selector must be separated by a comma.

The <h1> and <h2> elements share two declarations, so parts of the two rule sets can be combined to be more efficient as shown in Listing 2.10.

Listing 2.10. CSS Code Showing Combined Selectors
h1, h2
{
    text-align: center;
    color: navy;
}

h2
{
    font-style: italic;
}

p
{
    color: maroon;
}

Adding CSS Comments

Combining Selectors

CSS comments can be added to CSS to explain your code. Like HTML comments, CSS comments will be ignored by the browser. A CSS comment begins with /* and ends with */. Comments can appear before or within rule sets as well as across multiple lines. They also can be used to comment out entire rules or individual declarations.




Previous Page
Table of Contents
Next Page