Compartilhar via


fontSize property

Specifies a value that indicates the font size used for text in the object.

Syntax

Integer value = object.put_fontSize(Variant v);Integer value = object.get_fontSize(Variant* sSize);

Property values

Type: VARIANT

relative-size (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 (length)

Floating-point number, followed by an absolute units designator (cm, mm, in, pt, or pc) or a relative units designator (em, ex, or px). For more information about the supported length units, see the CSS Values and Units Reference.

percentage (percentage)

Floating-point number, followed by a percent (%). The value is a percentage of the parent object's font size.

String format

<absolute-size> | <relative-size> | <length> | <percentage>

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

This example sets the default font size for the document body, and then creates and applies CSS styles to change the font size.

body {
   font-size: 10pt;
}
.absolute {
   font-size: medium;
}
.relative {
   font-size: large;
}
.length {
   font-size: 14pt;
}
.percentage {
   font-size: 150%;
}
<body>
  <p>Lorem ipsum dolor sit amet... (<em>font-size: 10pt</em>)</p>
  <p class="absolute">Lorem ipsum dolor sit amet... (<em>font-size: medium</em>)</p>
  <p class="relative">Lorem ipsum dolor sit amet... (<em>font-size: large</em>)</p>
  <p class="length">Lorem ipsum dolor sit amet... (<em>font-size: 14pt</em>)</p>
  <p class="percentage">Lorem ipsum dolor sit amet... (<em>font-size: 150%</em>)</p>
</body>

The following image shows the result. The first line of text shows the default body element font size. The second line of text shows an absolute-size font-size setting. The third line of text shows a relative-size font-size setting. The fourth line of text shows a length font-size setting. The final line of text shows a percentage font-size setting:

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Mshtml.h

IDL

Mshtml.idl

DLL

Mshtml.dll

See also

Reference

IHTMLRuleStyle::font

Conceptual

CSS Values and Units Reference