HTML and CSS Reference
In-Depth Information
2.12. Stylesheets and JavaScript
Browsers also have support for two powerful innovations to HTML:
stylesheets and JavaScript. Like their desktop publishing cousins,
stylesheets let you control how your web pages looktext font styles
and sizes, colors, backgrounds, alignments, and so on. More important,
stylesheets give you a way to impose display characteristics uniformly
over the entire document and over an entire collection of documents.
JavaScript is a programming language with functions and commands that
let you control how the browser behaves for the user. Now, this is not a
JavaScript programming book, but we do cover the language in fair de-
tail in later chapters to show you how to embed JavaScript programs into
your documents and achieve some very powerful and fun effects.
The W3Cthe putative standards organizationprefers that you use the CSS
model for HTML/XHTML document design. All modern GUI browsers sup-
port CSS and JavaScript. The ancient Netscape 4 alone also supports a
JavaScript Style Sheet (JSS) model, which we describe in Chapter 12 ,
but we do not recommend that you use it. Let's rephrase thatdon't waste
your time on JSS. CSS is the universally approved, universally supported
way to control how your documents might (not will ) usually be displayed
on users' browsers.
To illustrate CSS, here's a way to make all the top-level ( h1 ) header text
in your HTML document appear in the color red:
<html>
<head>
<title>CSS Example</title>
<! Hide CSS properties within comments so old browsers
don't choke on or display the unfamiliar contents. >
<style type="text/css">
<!
h1 {color: red}
>
</style>
</head>
 
Search WWH ::




Custom Search