The style PropertyYou can use the style property to associate a CSS style with an element. You can see the support for this property in Table 5.53. Table 5.53. The style Property
The style property has many subproperties corresponding to the style attributes (such as color , fontWeight , and fontStyle ) that we'll see in Chapter 21, but here's a preview. In this example, I'll change the style of an <H1> header to italic when the user clicks a button: (Listing 05-21.html on the web site) <HTML> <HEAD> <TITLE>Using the style Property</TITLE> <SCRIPT LANGUAGE="JavaScript"> <!-- function styler() { document.body.style.fontStyle = "italic" } // --> </SCRIPT> </HEAD> <BODY> <H1 NAME="header1">Using the style Property</H1> <FORM> <INPUT TYPE="BUTTON" ONCLICK="styler()" VALUE="Click Me!"> </FORM> </BODY> </HTML> You can see the results in Figure 5.16. Figure 5.16. Using the style property.
|