HOME

DHTML Tutorial
DHTML HOME
DHTML Intro
DHTML CSS
DHTML DOM
DHTML Events

DHTML Examples
DHTML Examples

DHTML DOM
DOM window
DOM navigator
DOM event
DOM collection
DOM document
DOM form
DOM input
DOM select
DOM option
DOM textarea
DOM table
DOM tablerow
DOM tablecell
DOM anchor
DOM image
DOM frameset
DOM frame
DOM iframe

DOM Examples
DOM Examples

Resources
DHTML Books

Please visit our sponsors !

DHTML Cascading Style Sheets

previous next

HTML 4.0 introduced CSS, which gave us a style and layout model for HTML. With CSS, HTML elements can be styled with colors, backgrounds, borders, position, and visibility.


Examples

Note: Most of the DHTML examples require Internet Explorer 4.0 or higher.

Position:relative
How to position an element relative to its normal position.

Position:relative
How to position all your headings relative to its normal position.

Position:absolute
How to position an element using an absolute value.

Visibility
How to make an element invisible. Do you want the element to show or not?

Z-index
Z-index can be used to place an element "behind" another element, using Z-index priority.

Z-index
Check that the elements now have changed their Z-index priority.

Cursors
Change the style of the mouse cursor with CSS.

Filters
Change the style of your headings using the filter property.

Filters on Images 
The filter property can also used on images, here are some filter examples which look good on images.

Watermark
A background picture that does not move when the rest of the page is scrolling.


Position

The position property gives us the opportunity to place the elements anywhere on the document.

position:relative

This property places the element based on (or relative to) its current position.

H1
{
position:relative;
left:10;
}

This places the header 10 pixels to the right from where it is normally placed.

position:absolute

This property places the element out from the window's margins.

H1
{
position:absolute;
left:10;
}

This places the header 10 pixels to the right from the left-margin.


Visibility

The visibility property determines if an element is visible or not.

visibility:visible

This property makes the element visible.

H1
{
visibility:visible;
}

visibility:hidden

This property makes the element invisible.

H1
{
visibility:hidden;
}


Z-index

The z-index property determines the placement order of the elements.

H1
{
z-index:1;
}
H2
{
z-index:2;
}

The H1 element is placed before the H2 element, so if  these two elements happen to be placed on top of each other, the H2 element is placed on top of the H1 element.

 

Filters

Internet Explorer 4.0 introduced the filter property to CSS. The filter property allows you to add more style effects to your text and images.

H1
{
width:100%;
filter:glow;
}

The element you want to add a filter to, must have a specified width. There are many values to the filter property, this example shows the "glow" value, which produces this output:

Header


All the values have arguments that allow you to control the filters.

Filters

Property Value Syntax Explanation
alpha opacity
finishopacity
style
startx
starty
finishx
finishy 
filter:alpha(opacity=20, finishopacity=100, style=1, startx=0, 
starty=0, finishx=140, finishy=270)
Allows you to set the opacity of the element
blur add
direction
strength
filter:blur(add=true, directions=90, strength=80); Makes the element blur
chroma color filter:chroma(color=#ff0000) Makes the specified color transparent
fliph none filter:fliph; Flips the element horizontally
flipv none filter:flipv; Flips the element vertically
glow color
strength
filter:glow(color=#ff0000, strength=5); Makes the element glow
gray none filter:gray; Renders the element in black and white
invert none filter:inver; Renders the element in its reverse color and brightness values
mask color filter:mask(color=#ff0000); Renders the element with the specified background color, and transparent foreground color
shadow color
direction
filter:shadow(color=#ff0000, direction=90); Renders the element with a shadow
dropshadow color
offx
offy
positive
filter:dropshadow(color=#ff0000, offx=5, offy=5, positive=true); Renders the element with a dropshadow
wave add
freq
lightstrength
phase
strength
filter:wave(add=true, freq=1, lightstrength=3, phase=0, strength=5) Renders the element like a wave
xray none filter:xray; Renders the element in black and white with reverse color and brightness values

 


Background

The background property allows you to select your own background, in any style.

background-attachment:scroll

The background scrolls along with the rest of the page.

background-attachment:fixed

The background does not move when the rest of the page is scrolling.


previous next

Jump to: Top of Page or HOME or Printer Friendly Printer friendly page


Search W3Schools:


What Others Say About Us

Does the world know about us? Check out these places:

Dogpile Alta Vista MSN Google Excite Lycos Yahoo Ask Jeeves


We Help You For Free. You Can Help Us!


W3Schools is for training only. We do not warrant its correctness or its fitness for use. The risk of using it remains entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.

Copyright 1999-2002 by Refsnes Data. All Rights Reserved


Validate How we converted to XHTML Validate

IISCart
ASP Ecommerce & Shopping Cart


Your own Web Site?

Read W3Schools
Hosting Tutorial



ASP Hosting
ASP.net Hosting
Web Hosting



$15 Domain Name
Registration
Save $20 / year!



Advertise
at W3Schools

Only 0.5 CPM



SELECTED LINKS

Books Online

Web Software

The Future of
Web Development


Jobs and Careers

Web Security
Web Statistics
Web Standards


PARTNERS

W3Schools
TopXML
VisualBuilder
XMLPitstop
DevelopersDex
DevGuru
Programmers Heaven
The Code Project
Tek Tips Forum
ZVON.ORG
TopXML Search