Sets or retrieves a combination of separate font properties of the object. Alternatively, sets or retrieves one or more of six user-preference fonts. What's New for Microsoft® Internet Explorer 6
When you use the
!DOCTYPE declaration to specify standards-compliant mode, the default
font-size value for this composite property is
small, not
medium.
dhtml语法 HTML |
{ font : sFont }
|
---|
Scripting | object.style.font [ = sFont ] |
---|
DHTML可能的值 sFont | String that
specifies or receives up to six of the following space-delimited property values. Alternatively, sets or retrieves the six listed text fonts.font-style | Any of the range of font-style values available to the fontstyle property. | font-variant | any of the range of font-variant values available to the fontvariant property. | font-weight | any of the range of font-weight values available to the fontweight property. | font-size | any of the range of font-size values available to the fontsize property. when this value is an integer followed by a percent (%), the value is a percentage of the parent object's font size. in internet explorer 3.0, a percentage value is calculated as a percentage of the default font size. | line-height | any of the range of line-height values available to the lineheight property. when used with the font property, this attribute must include a slash (/) before the value. line height percentage values are calculated as a percentage of the font size of the element itself, not of the parent. | font-family | any of the range of font-family values available to the fontfamily property. this property can be set to multiple comma-separated values. its default value depends on user settings. | caption | user-preference font used in objects that have captionsbuttons, labels, and so on. | icon | user-preference font used in icon labels. | menu | user-preference font used in menus. | message-box | user-preference font used in dialog boxes. | small-caption | user-preference font used in small controls. | status-bar | User-preference font used in window status bars. |
|
The property is read/write.
The property has a default value of
normal normal normal medium normal "Times New Roman". The Cascading Style Sheets (CSS) attribute is
inherited.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see about dynamic properties.
remarks this is a composite property that specifies up to six font values. the font-style,
font-variant, and font-weight values may appear in any order before font-size. However, the font-size, line-height, and font-family properties must appear in the order listed. Setting the font property also sets the component properties. In this case, the string must be a combination of valid values for the component properties; only font-family may have more than one value.
If the string does not contain a value for a component property, that property is set to its default, regardless of prior settings for that component property. As of Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, the following conditions apply to this property.
- The font-size and font-family values must be declared. If font-size and font-family are not declared, or are not in the correct order, the font property is ignored.
- All specified values must appear in the correct order. Otherwise, the font property is ignored.
- In standards-compliant mode, the default font-size is small, not medium. If not explicitly set, font-size returns a point value.
For more information about standards-compliant parsing and the !DOCTYPE declaration, see css enhancements in internet explorer 6. when specifying the user preferences caption, icon, menu, message-box, small-caption, or status-bar for this property, do not set other values for the font property on the same element. if you do, the other values might render, but the user preference value is ignored.
Examples
The following examples use the font attribute and the font property to change font characteristics.
This example uses an inline style sheet to set the font attributes. <SPAN STYLE="font:italic normal bolder 12pt Arial">
:
</SPAN> This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
This example uses inline scripting to set the font properties. <DIV onmouseover="this.style.font = 'italic small-caps bold 12pt serif'">
:
</DIV> This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample. 是否符合公共标准
This property is defined in
Cascading Style Sheets (CSS), Level 1 (CSS1) .
Applies To |
A,
ADDRESS,
B,
BIG,
BLOCKQUOTE,
BODY,
BUTTON,
CAPTION,
CENTER,
CITE,
CODE,
COL,
COLGROUP,
CUSTOM,
DD,
defaults,
DFN,
DIR,
DIV,
DL,
DT,
EM,
FIELDSET,
FORM,
hn,
HTML,
I,
IMG,
INPUT type=button,
INPUT type=checkbox,
INPUT type=file,
INPUT type=image,
INPUT type=password,
INPUT type=radio,
INPUT type=reset,
INPUT type=submit,
INPUT type=text,
ISINDEX,
KBD,
LABEL,
LEGEND,
LI,
LISTING,
MARQUEE,
MENU,
OL,
NOBR,
P,
PLAINTEXT,
PRE,
runtimeStyle,
S,
SAMP,
SELECT,
SMALL,
SPAN,
STRIKE,
STRONG,
style,
SUB,
SUP,
TABLE,
TBODY,
TD,
TEXTAREA,
TFOOT,
TH,
THEAD,
TR,
TT,
U,
UL,
VAR,
XMP | |
更多语法参考 CSS Length Units
|