fontWeight style property
Specifies or returns the font weight of the text.
The currentStyle.fontWeight JavaScript property returns only integer values (100 - 900) in Internet Explorer.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: font-weight |
Possible values:
The type of this property is string.
One of the following values:
Font is normal. | |||||||
Font is bold. | |||||||
Font is bolder. | |||||||
Font is lighter. | |||||||
Not bolder than 200 weight. | |||||||
Not bolder than 300 weight. | |||||||
Not bolder than 400 weight. | |||||||
Font is normal. | |||||||
Not lighter than 400 weight and not bolder than 600 weight. | |||||||
Not bolder than 700 weight. | |||||||
Font is bold. | |||||||
Not lighter than 700 weight. | |||||||
Not lighter than 800 weight. | |||||||
Takes the value of this property from the computed style of the parent element. |
Default: normal.
Example HTML code 1:
This example illustrates the use of the font-weight property:
|
||||
<head> <style> .normal { font-weight: normal; } .bold { font-weight: bold; } </style> </head> <body> <span class="normal">font-weight: normal</span> <span class="bold">font-weight: bold</span> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the fontWeight property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeFont (selectTag) { // Returns the index of the selected option var whichSelected = selectTag.selectedIndex; // Returns the selected options values var selectState = selectTag.options[whichSelected].text; var fontTest = document.getElementById ("fontTest"); fontTest.style.fontWeight = selectState; } </script> </head> <body> <span id="fontTest"> Sample multiline text <br />change it! </span> <br /> <select onchange="ChangeFont (this);" size="7"> <option />bold <option />bolder <option />lighter <option />normal <option />300 <option selected="selected" />600 <option />900 </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: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:
color
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
textAlign
textAlignLast
textAutospace
textDecoration
textIndent
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
font
fontFamily
fontSize
fontSizeAdjust
fontStyle
fontVariant
textAlign
textAlignLast
textAutospace
textDecoration
textIndent
textJustify
textKashidaSpace
textOverflow
textShadow
textTransform
textUnderlinePosition
External links:
font-weight (MSDN)
font-weight (Mozilla Developer Center)
font-weight (Safari Reference Library)
font-weight (W3C)
font-weight (Mozilla Developer Center)
font-weight (Safari Reference Library)
font-weight (W3C)
User Contributed Comments