HTML and CSS Reference
In-Depth Information
other hand, style information must be incorporated into each page and contributes to making your
pages heavier.
The reuse of a style is possible, but only within the boundaries of a single page; to use the same
style from within different pages you would have to replicate the style definition in each page.
Using external files
Rather than inline or style tags, the recommended approach for styling HTML elements entails
the use of separate CSS files (or style sheets ) to which each page links autonomously. The browser
identifies the CSS content as a single URL and downloads it only once—regardless of how many pages
in the website use the styles in that style sheet. Moreover, the downloaded file can be cached at the
local computer and reused over and over again until the file expires, with no further download costs
for the browser.
Here's a brief example of how to define and link a style sheet to alter the default appearance of
a HTML page. From the New File dialog box shown in Figure 3-1, first create a new HTML page and
name it demo1.html , and then proceed to create a new style sheet named demo1.css .
FIGURE 3-1 Creating a new HTML page and style sheet.
Now open the HTML page and edit its content until it matches the code below:
<!DOCTYPE html>
<html>
<head>
<title>CSS Example</title>
</head>
<body>
<header>This is our header</header>
Search WWH ::




Custom Search