color style property
Specifies or returns the color of the element's text content.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: color |
Possible values:
The type of this property is string.
One of the following values:
Color of the text content. For the supported color values, see the colors page. | |||||||
Takes the value of this property from the computed style of the parent element. |
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the color property:
|
||||
<head> <style> .example1 { color: #9AEECC; } .example2 { color: #CCEE55; } </style> </head> <body> <h1 class="example1">text with color #9AEECC</h1> <h2 class="example2">text with color #CCEE55</h2> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the color property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeColor (selectTag) { // Returns the index of the selected option var whichSelected = selectTag.selectedIndex; // Returns the text of the selected option var selectState = selectTag.options[whichSelected].text; var anchor = document.getElementById ("myAnchor"); anchor.style.color = selectState; } </script> </head> <body> <a id="myAnchor">Change the color of the text</a> <select onchange="ChangeColor (this);" size="8"> <option />blue <option />red <option />cyan <option />white <option />green <option />yellow <option />purple <option selected="selected" />black </select> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
CSSStyleDeclaration, htmlElement.currentStyle, htmlElement.runtimeStyle, htmlElement.style
HTML elements:
a, abbr, acronym, address, b, basefont, bdo, big, blink, blockquote, body, button, caption, center, cite, code, col, colgroup, dd, del, dfn, dir, div, dl, dt, em, fieldset, font, form, h1, h2, h3, h4, h5, h6, html, i, input:button, input:file, input:password, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, label, legend, li, listing, marquee, menu, nobr, ol, optgroup, option, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
Related pages:
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
fontWeight
textAlign
textAlignLast
textAutospace
textDecoration
textIndent
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
fontWeight
textAlign
textAlignLast
textAutospace
textDecoration
textIndent
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
External links:
User Contributed Comments