CSS and DHTML

JavaScript and the HTML data object model can be used to change the looks of any HTML tag. Each CSS property can be referenced from JavaScript with this.style.property = newValue. Here is a short code that changes the color of the text inside a DIV block.

HTML Example:

Hello!

Result:

Hello!

The simplest way to refer to an HTML tag is by its ID, like in the example above. Other JavaScript functions like getElementsByName() will return an array of references you have to loop through.

Share

Learn how to design amazing websites