color Attribute | color Property
Sets or retrieves the color of the text of the object.
Syntax
HTML { color : sColor } Scripting object.style.color [ = sColor ]
Possible Values
sColor String that specifies one of the color names or red-green-blue (RGB) values in the Color Table. The property is read/write with no default value; the cascading style sheets (CSS) attribute is inherited.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see dynamic properties.
Remarks
These are different ways to specify a color—in this example, red.
EM { color: red } /* natural language / CNS */ EM { color: #F00 } /* #RGB */ EM { color: #FF0000 } /* #RRGGBB */ EM { color: rgb 1.0 0.0 0.0 } /* float range: 0.0 - 1.0 */Some browsers do not recognize color names, but all browsers should recognize red-green-blue (RGB) color values and display them correctly.
Windows CE
In Microsoft® Windows® CE, specifying a value for the color property of the OPTION element when applied through the style object has no effect.
Example
The following examples use the color attribute and the color property to change the text color of an object.
This example uses a call to an embedded (global) style sheet to change the text color to red when an onmouseover event occurs.
Sample Code
<STYLE> .color1 { color:red } .color2 { color: } </STYLE> </HEAD> <BODY> <SPAN STYLE="font-size:14" onmouseover="this.className='color1'" onmouseout="this.className='color2'"> . . .This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.This example uses inline scripting to change the text color to red when an onmouseover event occurs.
<SPAN STYLE="font-size:14" onmouseover="this.style.color='red'"> : </SPAN>
Applies To
[ Object Name ] Platform Version Win16: Win32: Mac: Unix: WinCE: Version data is listed when the mouse hovers over a link, or the link has focus. A, ADDRESS, APPLET, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, currentStyle, custom, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, Hn, HTML, I, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, OPTION, P, PLAINTEXT, PRE, runtimeStyle, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP
Did you find this topic useful? Suggestions for other topics? write us!
© 1999 microsoft corporation. all rights reserved. terms of use.