Style fontVariant attribute

Definition and usage

fontVariant Attribute 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 be smaller in font size compared to the rest of the text.

See also:

CSS Tutorial:CSS Γραμματοσειρά

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 Font is normal. Default.
small-caps Font displayed in small caps.
initial Set this property to its default value. See initial.
inherit Inherit this property from its parent element. See inherit.

Technical details

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

Υποστήριξη Βrowser

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη Υποστήριξη