Skip to Main Content
HTML & XHTML: The Definitive Guide, 6th Edition
book

HTML & XHTML: The Definitive Guide, 6th Edition

by Chuck Musciano, Bill Kennedy
October 2006
Intermediate to advanced content levelIntermediate to advanced
680 pages
21h 44m
English
O'Reilly Media, Inc.
Content preview from HTML & XHTML: The Definitive Guide, 6th Edition

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 look—text 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 detail in later chapters to show you how to embed JavaScript programs into your documents and achieve some very powerful and fun effects.

The W3C—the putative standards organization—prefers that you use the CSS model for HTML/XHTML document design. All modern GUI browsers support 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 that—don'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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

CSS Master, 3rd Edition

CSS Master, 3rd Edition

Tiffany B Brown

Publisher Resources

ISBN: 0596527322Errata Page