10.07.2017 Views

246996016-HTML5-Step-by-Step

Create successful ePaper yourself

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

Key Points 101<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

●<br />

There are three ways to apply a style. You can use the style attribute within an<br />

individual tag, you can create an embedded style sheet, or you can create an external<br />

style sheet.<br />

You place an embedded style sheet in the section of the file and enclose<br />

it in a tag. An external style sheet is a separate plain text file with a .css<br />

extension.<br />

A style sheet consists of one or more style rules. A style rule is the tag, class, or ID<br />

name followed <strong>by</strong> curly braces in which the specifications are placed.<br />

Each specification takes the format of name: value. For example, list-style-type:<br />

square.<br />

Separate multiple specifications within a rule <strong>by</strong> using semicolons. To define two or<br />

more tags the same way, include both tags (with a comma between them) before<br />

the opening curly brace, like this: h1, h2 {color: black}. If you omit the comma, two<br />

tag names in a row refer to nested styles in a rule. For example, ol ul {color: green}<br />

refers to unordered lists nested within ordered lists.<br />

You can assign a class to multiple elements. You can define a style based on a class.<br />

Precede a class’s name in a style sheet with a period, like this: .new {color: red}.<br />

An ID must be uniquely assigned within a document. You can define a style based<br />

on an ID. Precede the ID in a style sheet with a hash symbol (#), like this: #special<br />

{color: red}.<br />

Apply a class or ID to a tag <strong>by</strong> including the class or ID attribute within its opening<br />

tag, like this: .<br />

To apply styles to hyperlinks, use a pseudo-class of the hyperlink type. You can<br />

apply the link, visited, hover, active, or focus pseudo-class like this: a:visited<br />

{color: red}.<br />

To create an external style sheet, start a new Notepad document and place all the<br />

style rules within it. Then refer to it from the section of each document<br />

to which that style sheet should apply, <strong>by</strong> using the tag , where default.css is the name of your style sheet.

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

Saved successfully!

Ooh no, something went wrong!