Set the font of an element to "small-caps":
document.getElementById("demo").style.fontVariant = "small-caps";
Try it Yourself »
The fontVariant property sets or returns whether the font should be displayed in small capital letters.
This means that all lowercase letters will be converted to uppercase, but the letters will have a smaller font-size compared to the rest of the text.
Property | |||||
---|---|---|---|---|---|
fontVariant | Yes | Yes | Yes | Yes | Yes |
Return the fontVariant property:
object.style.fontVariant
Set the fontVariant property:
object.style.fontVariant = "normal|small-caps|initial|inherit"
Value | Description |
---|---|
normal | The font is normal. This is default |
small-caps | The font is displayed in small capital letters |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | normal |
---|---|
Return Value: | A String, representing a font in either normal or small capital letters |
CSS Version | CSS1 |
Return the font variant of an element:
alert(document.getElementById("demo").style.fontVariant);
Try it Yourself »
CSS tutorial: CSS Font
CSS reference: font-variant property
HTML DOM reference: font property
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!