Skip to Main Content
ASP.NET 4 24-Hour Trainer
book

ASP.NET 4 24-Hour Trainer

by Toi B. Wright
July 2010
Beginner content levelBeginner
552 pages
10h 14m
English
Wrox
Content preview from ASP.NET 4 24-Hour Trainer

Chapter 3. Adding Style to an HTML Page

In this lesson you learn how to use cascading style sheets (CSS) to add style to an HTML page. As I said in Lesson 1, HTML defines the structure of a page, while cascading style sheets define the styles on a page. They can be used to define colors, fonts, and background images and they can be used for page layout. There are over 90 properties that you can use to style your HTML.

CSS RULES

A cascading style sheet is made-up of a collection of CSS rules. This is the CSS rule to modify the colors used by the <h1> tag:

h1 {color:White; background-color:Silver}

This CSS rule sets the text color of all of your <h1> tags to white and their background color to silver, as shown in Figure 3-1.

A CSS rule consists of a selector and one or more declarations. Each declaration is made up of a property and a value, as shown in Figure 3-2.

FIGURE 3-1

Figure 3.1. FIGURE 3-1

FIGURE 3-2

Figure 3.2. FIGURE 3-2

As you can see in Figure 3-2 each declaration is separated by a semicolon. Another way to write this CSS rule is to type each declaration on its own line:

h1
{
    color: White;
background-color: Silver;
}

In the preceding example, all of the <h1> tags on the entire page will be displayed using the new H1 style. If you do not want your style to be applied to every instance of a particular HTML ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 4 24-Hour Trainer

ASP.NET 4 24-Hour Trainer

Toi B. Wright
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9780470596913Purchase bookExamplesErrata