HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 9. CSS: THE STYLE SHEET 91


Thetags identify a style sheet. (You can have more
than one.) Put your main style sheet someplace between yourand


tags.

Web browsers will also accept style sheet material other places in your doc-
ument, but the best place to put it is in the head.


The material inside the style section is called an internal style sheet. It is
possible to have an external style sheet that is shared among many webpages,
but this internal style sheet is used by just this webpage.


The language used in your webpage is HTML, but within the style sheet, the
language is called CSS, or Cascading Style Sheet language. It has somewhat
different linguistic rules than HTML does.


Exam Question 161(p.346): What does CSS stand for?
Acceptable Answer:cascading style sheet


Within a style sheet, all CSS looks the same as this prototype:


target { attribute: values; attribute: values; ... }


The attribute list for a target is enclosed in curly braces. Individual at-
tributes are separated from their values a colon, and terminated (separated
from the next attribute) by a semi-colon.


Exam Question 162(p.346): Give the prototype for CSS directives.
Acceptable Answer:target{attribute: value; ...}


In this chapter we will look at targets that are actual HTML tags. Later,
in section 10.1 (page 99), we will look at IDs and classes as targets.


We are familiar with thetag. We can use it in CSS to apply styling
to the whole body of the webpage.


body { background-color: yellow; }


If we include that line in our style sheet, the background of the whole web-
page will turn yellow.


We can use a similar approach to control the styling of

,

,

,
and all other tags.


9.1 Why Bother With Style Sheets?


People that create content generally do the markup on that content.

← Previous
Free download pdf