Home > Articles > Web Services > XML

What Are CSS and DHTML?

  • Print
  • + Share This
In this sample chapter, author Dan Livingston teaches you how to maintain control over your Web pages, and even your Web site as a whole, which can save you and your users lots of time.
This sample chapter is excerpted from Essential DSS and DHTML for Web Professionals, by Dan Livingston.
This chapter is from the book

Welcome to the world of CSS (cascading stylesheets) and DHTML (dynamic HTML) (technically, it's "Dynamic HTML" without HTML being spelled out)! There's lots of good stuff here that gives you great control over your Web pages, and even your Web site as a whole, which can save you and your users lots of time. Using CSS and DHTML can also be one of the most frustrating things you've ever done if you don't pay close attention to what you're doing (trust me on this one—the stories I could tell...). So, let's go ahead and get started.

What Is CSS?

CSS stands for "cascading stylesheets," but we'll just be calling them "stylesheets" from now on. For all practical purposes, stylesheets are as much a part of HTML as the <img>and <table> tags. Adding stylesheet information to a page is just a matter of typing in some extra code. There's nothing fancy about it.

 Placing stylesheet information into a Web page lets you set certain aspects of that HTML page. For example, your stylesheet could say, "Make all of the text in this Web page 16 point bold Arial," or "There's a layer called 'banner' and it's located at 60 pixels over and 90 pixels down," or even "When the <b> tag is used, make that text both bold and italic." CSS is a standard created by the World Wide Web Consortium, the same folks who define exactly what HTML is. There are several versions of CSS (the third version, CSS3, is being worked on right now). The browsers all implement variations of the first two versions, CSS1 and CSS2. You don't need to be concerned about them in this book—we'll look at what works without worrying about which version it is.

What Can CSS Do?

Stylesheets can do three things:

  1. Set the font of text on a page

  2. Define a layer and position it on the page

  3. Modify HTML tags

If you decide to use stylesheets to set your page's fonts, you can define different classes of fonts, like "headlineText" or "footerText" or "mainBodyText," and use different fonts for all three. This may not sound exciting, but if used properly, this can save you hours and hours that you'd otherwise spend using the nasty and decrepit <font>tag.

When Is CSS Really Used?

Stylesheets are really used only for the first two items above: setting fonts and positioning layers. You can use stylesheets to modify HTML tags, but I (and most other Web developers) haven't found that to be very useful. It tends to confuse more than to facilitate. So, I'll be concentrating mostly on using stylesheets to set fonts and position layers throughout this book. I'll show you how to modify tags, but there won't be a lot of examples—that would be like showing you the proper way to ride a bicycle underwater. I'll show you how to do it, but an extended tour wouldn't serve any real purpose.


To be fair, there are developers who find modifying HMTL tags to be useful, and they modify vague tags to mean something specific, like the EMor STRONGtags. Experiment to see what you prefer.

  • + Share This
  • 🔖 Save To Your Account