CSS Property: font-variant
[this page | pdf | back links]
The CSS (CSS1) font-variant property indicates
whether text should be in a small-caps font (in which all lowercase letters are
converted to slightly smaller uppercase letters).
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
normal
|
(default value). Normal
text
|
small-caps
|
Text is shown in a
small-caps font
|
Default Value:
|
normal
|
JavaScript syntax:
|
e.g. object.style.fontVariant="small-caps"
|
Inherited:
|
Yes
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; border: 1px dotted black;}
.x1 {font-variant: small-caps;}
</style>
</head>
<body>
Note: not all browsers recognise this style<br>
Element with default property<br>
<div>Abcd Efgh</div><br>
Property set using in-file HTML style<br>
<div class="x1">Abcd Efgh</div><br>
Property set using JavaScript<br>
<div id="x2">Abcd Efgh</div>
<script>
document.getElementById("x2").style.fontVariant = "small-caps";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyFontVariant() {
var x = document.createElement("DIV"); x.style.fontVariant = "small-caps"; return (window.getComputedStyle(x, null).fontVariant == "small-caps");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties