/

HTML / CSS / JavaScript Tutorial

CSS Property: font-size-adjust

[this page | pdf | back links]

The CSS (CSS3) font-size-adjust property gives better control of the font size than is provided by the font-size property alone, when the first font selected in the font-family property is not available.  All fonts have an “aspect value” which is the size-difference between the lowercase “x” and the uppercase “X”. If the browser is told this value then it can figure out what font-size to use when displaying text from the entry in the font-family property that is actually used.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

number

A value indicating the aspect value to use

none

(default value). No adjustment applied to font size

 

Default Value:

none

JavaScript syntax:

e.g. object.style.fontSizeAdjust="0.58"

Inherited:

Yes

Animatable:

Yes

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; border: 1px dotted black; font-family: serif}
.x1 {font-size-adjust: 0.8;}
</style>
</head>
<body>
Note: most browsers do not support this style
Element with default property<br>
<div>abcdefgh</div><br>
Property set using in-file HTML style<br>
<div class="x1">abcdefgh</div><br>
Property set using JavaScript<br>
<div id="x2">abcdefgh</div>

<script>
document.getElementById("x2").style.fontSizeAdjust = "0.8";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyFontSizeAdjust() {
  var x = document.createElement("DIV"); x.style.fontSizeAdjust = "0.8"; return (window.getComputedStyle(x, null).fontSizeAdjust == "0.8");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile