fontVariant Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:fontVariant

Description

The fontVariant property sets or gets whether the font should be displayed in small capital letters.

All lowercase letters will be converted to uppercase, but the letters will have a smaller font-size.

Property Values

Value Description
normal The font is normal. This is default
small-caps The font is displayed in small capital letters
initialSets this property to its default value.
inheritInherits this property from its parent element.

Technical Details

Item Value
Default Value: normal
Return Value: A String, representing a font in either normal or small capital letters
CSS VersionCSS1

Set a <p> element to a small-caps font:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="font-variant:small-caps">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {//from  www .  j  a v a 2 s . c om
    document.getElementById("myP").style.fontVariant = 'normal';
}
</script>

</body>
</html>

Related Tutorials