What Are CSS and DHTML?
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 onethe 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 bookwe'll look at what works without worrying about which version it is.
What Can CSS Do?
Stylesheets can do three things:
Set the font of text on a page
Define a layer and position it on the page
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 examplesthat 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.