Style fontVariant Attribute
- Previous Page fontStyle
- Next Page fontWeight
- Go to Parent Layer HTML DOM Style Object
Definition and Usage
fontVariant
Attribute to set or return whether the font is displayed as small caps.
This means that all lowercase letters will be converted to uppercase, but these letters will have a smaller font size compared to the rest of the text.
See Also:
CSS Tutorial:CSS Font
CSS Reference Manual:font-variant Attribute
HTML DOM Reference Manual:font Property
Instance
Example 1
Sets the <p> element to small caps font:
document.getElementById("myP").style.fontVariant = "small-caps";
Example 2
Returns the font variant of the <p> element:
alert(document.getElementById("myP").style.fontVariant);
Syntax
Return fontVariant property:
object.style.fontVariant
Set fontVariant property:
object.style.fontVariant = "normal|small-caps|initial|inherit"
Attribute Value
Value | Description |
---|---|
normal | The font is normal. Default. |
small-caps | The font is displayed in small caps. |
initial | Sets this property to its default value. See also initial. |
inherit | Inherits this property from its parent element. See also inherit. |
Technical Details
Default value: | normal |
---|---|
Return value: | A string representing a font style for normal or small caps. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page fontStyle
- Next Page fontWeight
- Go to Parent Layer HTML DOM Style Object