textDecoration style property
Specifies or returns the appearance characteristics of text, whether it is underlined, overlined, lined-through or blinking text.
You can specify a space separated list of decoration types, if you want to use more than one for an element.
To manipulate the text-decoration types separately, use the textDecorationBlink, textDecorationLineThrough, textDecorationNone,
textDecorationOverline or the textDecorationUnderline properties.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: text-decoration |
Possible values:
The type of this property is string.
One of the following values: | ||||||||||||||||||
|
Description of values:
Use default anchor decoration. | |||||||
The text content of the element blinks. | |||||||
Takes the value of this property from the computed style of the parent element. | |||||||
The text content of the element is displayed with a line through the middle. | |||||||
No text decoration is used. | |||||||
The text content of the element is displayed with a line at the top. | |||||||
The text content of the element is underlined. |
Default: none.
Example HTML code 1:
This example illustrates the use of the text-decoration property:
|
||||
<head> <style> .example { text-decoration: overline line-through; } </style> </head> <body> <a class="example">Text decoration: overline line-through</p> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the textDecoration property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeTextDecoration (elem) { var anchor = document.getElementById ("myAnchor"); var checkboxes = document.getElementsByName ("checkboxs"); var decorValue = ""; // Checks all checkbox state for (var i = 0; i < checkboxes.length; i++) { if (checkboxes[i].checked) { decorValue += checkboxes[i].value + " "; } } // If none is checked all other checked out var noneCh = document.getElementsByName("nonecheck"); if (noneCh[0].checked) { for (var i = 0; i < checkboxes.length; i++) { checkboxes[i].checked = false; } decorValue = "none"; } anchor.style.textDecoration = decorValue; } </script> </head> <body> <a id="myAnchor">Text decoration sample</a> <br /><br /> Change text-decoration value: <br /> <input type="checkbox" name="checkboxs" value="blink" onclick="ChangeTextDecoration ();"/>blink<br /> <input type="checkbox" name="checkboxs" value="line-through" onclick="ChangeTextDecoration ();"/>line-through<br /> <input type="checkbox" name="checkboxs" value="overline" onclick="ChangeTextDecoration ();"/>overline<br /> <input type="checkbox" name="checkboxs" value="underline" onclick="ChangeTextDecoration ();"/>underline<br /> <input type="checkbox" name="nonecheck" onclick="ChangeTextDecoration ();" />none </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: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:
textDecorationBlink
textDecorationLineThrough
textDecorationNone
textDecorationOverline
textDecorationUnderline
color
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
fontWeight
textAlign
textAlignLast
textAutospace
textIndent
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
textDecorationLineThrough
textDecorationNone
textDecorationOverline
textDecorationUnderline
color
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
fontWeight
textAlign
textAlignLast
textAutospace
textIndent
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
External links:
text-decoration (MSDN)
text-decoration (Mozilla Developer Center)
text-decoration (Safari Reference Library)
text-decoration (W3C)
text-decoration (Mozilla Developer Center)
text-decoration (Safari Reference Library)
text-decoration (W3C)
User Contributed Comments