Style fontVariant attribute

Definition and usage

fontVariant Property sets or returns 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 skrifttype

CSS Reference Manual:font-variant attribute

HTML DOM Reference Manual:font property

Instance

Example 1

Set the <p> element to small caps font:

document.getElementById("myP").style.fontVariant = "small-caps";

Try it yourself

Example 2

Return the font variant of the <p> element:

alert(document.getElementById("myP").style.fontVariant);

Try it yourself

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 initial.
inherit Inherits this property from its parent element. See inherit.

Technical details

Default value: normal
Return value: A string that represents the font for normal or small caps.
CSS version: CSS1

Browser understøttelse

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support