Click here!

Upload    Contact    Home


R E S O U R C E S

HTMLStuff:

 
 
Home
Artist
Designer
Webmaster
Programmer
What's New
* Resources
 

 

 

Basic DHTML for Internet Explorer: The CSS

The CSS
     Cascading style sheets are what define how DHTML elements look and behave. For information on style sheets visit our "How to Make Cascading Style Sheets" tutorial. Without CSS, we wouldn't have any handles on the <div> tags to which we can hang on to. Let's look at the example DHTML page again.

DHTML Page Each block has a set of attributes that specify how it looks and works.

     Above, each DHTML block has a set of attributes that control how the element looks and works. The text block has a position of 200 pixels from the left and 250 pixels from the top. It also defines what type of font to use as well as color. All this is done with inline style sheets. By adding a style attribute with a list of style definitions enclosed in double quotes to a <div> tag, we order the browser to take this block and display it how we want it. Below is what the code of the text block looks like.

   <div id="story"
   style="position: absolute;
   top: 250;
   left: 200;
   width: 400;
   z-index: 1;
   font-family: 'tahoma';
   color: #333333">
   
      A pleasing land of drowsy head it was,<br>
      ...
   
   </div>
     Notice how we had the style attribute span a line for every definition. This is done just to increase readability. By using the various CSS selectors and assigned values to describe the block, we define a type of personality for the whole block. For a listing of the CSS selectors visit our List of CSS Properties And Values reference. Everything within the <div> tags is then limited to these characteristics.

     Now what's the deal with the two sub blocks containing the two sword images? The two sub blocks inherit the position attributes from the larger block and are positioned relative to the larger block's position. Below is the code for the two sub blocks.

  1. <!-- -------------CONTROL BLOCK------------- -->
  2. <div id="controls"
  3. style="position: absolute;
  4. top: 100;
  5. left: 700;
  6. width: 50;
  7. height: 300;
  8. Z-Index: 1;
  9. Visible: true">
  10. <div id="scrollup"
  11. style="position: absolute;
  12. top: 0;
  13. left: 0">
  14. <img src="up.gif" alt="Scroll Up">
  15. </div>
  16. <div id="scrolldown"
  17. style="position: absolute;
  18. top: 200;
  19. left: 0">
  20. <img src="down.gif" alt="Scroll Down">
  21. </div>
  22. </div>
     Look at lines 12 and 19. Notice the <div> tags are within another <div> tag which means any top or left values given to the inner blocks will use the outer block's position as the origin. That's because the inner <div> tags of the controls element inherit the controls element's position. Don't forget the hierarchy.

     Now that you've had a taste of what part CSS has in DHTML, you can go on to the next part which describes the "dynamic" part of dynamic HTML.

Basic DHTML with Internet Explorer
     Part 1: The HTML
     Part 2: The CSS
     Part 3: The Script
Related Article: Introduction to DHTML

Have a comment or question dealing with this tutorial? Write us!


Back to Tutorial Menu
Back to Designer Main Page
Back To HTML Stuff Main Page

 

  News   Contact   Advertise   CD ROM   Search   Upload   Help   Home

Copyright © 2000 Tucows.Com Inc.
TUCOWS.Com Inc. has no liability for any content or goods on the TUCOWS site or the Internet, except as set forth in the terms and conditions and privacy statem ent.