Home > Articles > Web Services > XML

  • Print
  • + Share This
This chapter is from the book

What Is DHTML?

DHTML literally stands for "dynamic HTML." However, DHTML really means using JavaScript to manipulate stylesheets; that is, using JavaScript to hide, display, or move layers, or to change the font of some text as a user rolls a mouse over it. That's really it. Here's another way to think of it: You can use JavaScript to manipulate HTML, right? Think about image rollovers and placing text in form fields—that's using JavaScript to change what's on the Web page. DHMTL is exactly that: using JavaScript to change what's on a page. If you're changing something that was set in a stylesheet, like layers or fonts, you're suddenly doing DHTML instead of plain ol' JavaScript. "DHTML" is just a marketing term that stands for a certain type of JavaScript usage.

If this isn't clear right now, don't worry. It will be. I'll spend the next chapter looking at stylesheets and the rest of the book will look at using JavaScript.

What Can DHTML Do?

DHTML can do all sorts of really interesting and fun things. You can create little games, sliding pop-up menus, draggable images, interactive quizzes, and the like. Internet Explorer (IE), especially, has all sorts of great extensions that will let you get pretty creative. There's no end to the things you can do.

The Limitations of DHTML

The only real limitation of DHTML is the wildly different ways JavaScript is treated in the different browsers. This is a big, fat, hairy limitation. For example, I once created a scrolling multiple-line text field in DHTML. It had arrows, a slider bar, everything. It took longer to build that little scrolling thing so that it worked on all browsers and platforms than it took to build the rest of the site (including the back-end database stuff), almost. Building it for one browser and platform wasn't too tough, but once I started looking at the other browsers and platforms, the development time increased tremendously. Needless to say, I gladly dumped it at the next revision of the site—it just took too much time.

I bring up this story as a potential warning: If you get really fancy with DHTML, you will pay. Development time to make your code work on the various browsers and platforms will take way longer than it should. If you think you're done, look at your page on a Macintosh running IE 4.5.

Everything in this book is fully cross-browser and cross-platform. In fact, I'm ignoring everything that's Netscape-specific or IE-specific. As of this writing, Netscape hasn't completely lost the browser war yet, so Netscape users must still be considered. Also, Netscape 6 is less popular than expected, so Netscape 4.x users must still be considered and coded for.

When to Use DHTML

To be honest, I only use DHTML to make layers appear and disappear, and for simple animation. However, not everyone has such pedestrian ambitions for their DHTML, so you'll find examples that go beyond those few uses in this book. In fact, I expect to see a lot more DHTML on the Web fairly soon, now that almost everyone has Netscape 4.7+ and IE 5.x. All the browser metrics I've seen indicate that at least 95% of Web surfers have a 4.0+ browser.

When you start to code your own DHTML, start small and simple. It's easy to make large promises to a client, and as a brilliant programmer, I'm sure you'll deliver on them, but you'll save yourself a lot of heartache and late nights if you build your pages in incremental phases.

  • + Share This
  • 🔖 Save To Your Account