HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 28. STYLING WITH CSS 260


28.3 External Style Sheet


External style sheets (or, stylesheets, without the space) can be shared
among many webpages.


...

Then, in a totally separate file, in this case, in (docroot)/style.css, we would
have this content:


.red { color: red; }


The external style sheet gets “included” into your webpage by reference. It
is pretty much the same as if you had pasted it into your webpage between
atag set.


Notice that the external style sheet does not have any html tags. Specifically,
it does not start withas an internal style
sheet would.


The advantage of using an external style sheet is that the same style sheet
can be used by many webpages, and corrections to the style sheet can be
made in a single place, and have immediate effect everywhere that style
sheet is used.


28.4 Box Model: Padding, Border, Margin


The Box Model has its own chapter: 12 (page 126). We summarize here
briefly, and give a few examples, but see the chapter for details.


padding: 5px;
border: solid black 3px;
margin: 5px auto;


Webpage content is naturally rectangular. Someday that might change, but
for now it is rectangular. It is possible to flow content around these boxes.
See the float: and clear: styles elsewhere.

Free download pdf