Datasheet

1 2 3 4 5 6 7 8 9 10
1
Introducing
Cascading Style Sheets
Cascading style sheets is a language intended to simplify website design and development. Put
simply, CSS handles the look and feel of a web page. With CSS, you can control the color of text, the
style of fonts, the spacing between paragraphs, how columns are sized and laid out, what back-
ground images or colors are used, as well as a variety of other visual effects.
CSS was created in language that is easy to learn and understand, but it provides powerful
control over the presentation of a document. Most commonly, CSS is combined with the markup
languages HTML or XHTML. These markup languages contain the actual text you see in a web
page the hyperlinks, paragraphs, headings, lists, and tables and are the glue of a web docu-
ment. They contain the web page’s data, as well as the CSS document that contains information
about what the web page should look like, and JavaScript, which is another language that pro-
vides dynamic and interactive functionality.
HTML and XHTML are very similar languages. In fact, for the majority of documents today, they
are pretty much identical, although XHTML has some strict requirements about the type of syntax
used. I discuss the differences between these two languages in detail in Chapter 2, and I also pro-
vide a few simple examples of what each language looks like and how CSS comes together with
the language to create a web page. In this chapter, however, I discuss the following:
The W3C, an organization that plans and makes recommendations for how the web
should function and evolve
How Internet documents work, where they come from, and how the browser displays
them
An abridged history of the Internet
Why CSS was a desperately needed solution
The advantages of using CSS
05_096970 ch01.qxp 4/20/07 11:27 PM Page 3
COPYRIGHTED MATERIAL

Summary of content (22 pages)

’Uranus’

Uranus

  • Distance from the Sun: 2,870,972,200 km
  • Equatorial Radius: 25,559 km
  • Volume: 69,142,000,000,000 km3
  • Mass: 86,849,000,000,000,000,000,000,000 kg
  • PAGE 17

    Chapter 1: Introducing Cascading Style Sheets 2. 3. Save the preceding file in a new folder of its own as index.html. Create a new, blank document in your text editor, and enter the following CSS: body { margin: 0; padding: 0; background: #000 url(‘images/backgrounds/star.

  • PAGE 18

    Part I: The Basics } div.planet-copy { color: white; padding: 10px; margin-left: 520px; background: #000 url(‘images/backgrounds/star_darker_still.png’) no-repeat fixed; position: absolute; top: 0; bottom: 0; left: 0; border-left: 1px solid #000; border-right: 1px solid #000; } div.planet-copy h1 { border-bottom: 1px solid #000; margin: 0 -10px; padding: 0 10px; } div.planet-copy ul { list-style: none; } 4. 5. Save the preceding CSS in the same folder where you saved index.html, as solar_system.css.

  • PAGE 19

    Chapter 1: Introducing Cascading Style Sheets Figure 1-5 You might also note that Example 1-1 took some additional handy work to make it come out the same in Internet Explorer, as it did in Safari, Firefox, and Opera. Throughout this book, you also learn the hacks and workarounds that you need to make CSS-enabled web pages compatible with IE 6.

  • PAGE 20

    Part I: The Basics ❑ The presentation of an entire website can be centralized to one or a handful of documents, enabling the look and feel of a website to be updated at a moment’s notice. In legacy HTML documents, the presentation is contained entirely in the body of each document. CSS brings a much needed feature to HTML: the separation of a document’s structure from its presentation. CSS can be written independently of HTML.

  • PAGE 21

    Chapter 1: Introducing Cascading Style Sheets ❑ CSS has many advantages. These include being accessible, applicable to more than one language; applicable to more than one type of device, and allowing a website to be planned, produced, and maintained in much less time. CSS also enables a website to take up significantly less hard disk space and bandwidth than formerly possible.

  • PAGE 22