HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 9. CSS: THE STYLE SHEET 92


People that design styles generally do NOT create the content. It requires
a different skill set that is probably more artistic.


It is widely accepted that the styling (CSS) and the content (HTML) should
be kept separate so that changes to styling do not require any changes to
the content.


The same holds true for JavaScript. It can be hidden inside the content, or
it can be kept separate. It is better to keep it separate.


9.2 Style Sheet vs Inline Styling


To give all paragraphs a yellow background, we could insert the following
line into a style sheet.


p { background-color: yellow; }


Inline Styling: To give one specific paragraph a yellow background, we
could use the following in place of the

tag.



or:


9.3 background-color:


As we have just seen, thebackground-color: attribute can be used to
control the background color of a webpage. We talked about color in Chapter
7 (page 71). Feel free to experiment.


Exam Question 163(p.346):What CSS attribute: sets the color behind
your lettering?
Required Answer:background-color:


9.4 color:


Thecolor:attribute can be used to control the foreground color of the text
on a webpage.


Exam Question 164(p.346):What CSS attribute: sets the color of your
lettering?

Free download pdf