font-size property
Sets or retrieves a value that indicates the font size used for text in the object.
Syntax
font-size:
<absolute-size>
|
<relative-size>
|
<length>
|
<percentage>
Property values
- absolute-size
-
Set of keywords that indicate predefined font sizes. Named font sizes scale according to the user's font setting preferences. Possible values include the following: xx-small, x-small, small, medium, large, x-large, xx-large.
- relative-size
-
Set of keywords that are interpreted as relative to the font size of the parent object. Possible values include the following: smaller, larger.
- length
-
Floating-point number, followed by an absolute units designator (
cm,mm,in,pt, orpc) or a relative units designator (em,ex, orpx). For more information about the supported length units, see the CSS Values and Units Reference. - percentage
-
Floating-point number, followed by a percent (%). The value is a percentage of the parent object's font size.
CSS information
| Applies To | All elements |
|---|---|
| Media | visual |
| Inherited | 1 |
| Initial Value | medium |
Remarks
Negative values are not allowed. Font sizes using the proportional "em" measure are based on the font size of the parent object.
As of Microsoft Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, the default value for this property is medium, not small.
Possible length values specified in a relative measurement, using the height of the element's font (em) or the height of the letter "x" (ex), are supported in Microsoft Internet Explorer 4.0 and later.
Examples
The following examples use the font-size attribute and the font-size property to change font characteristics.
This example sets the font size on several paragraphs using different size values.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/font-size.htm
<style type="text/css">
body{font-size: 10pt }
.p1 {font-size: 14pt }
.p2 {font-size: 75% }
.p3 {font-size: xx-large }
.p4 {font-size: larger }
</style>
This example uses inline scripting to set the font size to 14pt when an onmouseover event occurs.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/fontSize.htm
<div style="font-size:12pt" onmouseover="this.style.fontSize='14pt'"> : </div>
See also
- CSSStyleDeclaration
- currentStyle
- defaults
- runtimeStyle
- style
- Reference
- font
- Conceptual
- CSS Values and Units Reference
Send comments about this topic to Microsoft
Build date: 11/29/2012
