/

HTML / CSS / JavaScript Tutorial

CSS Property: font-stretch

[this page | pdf | back links]

The CSS (CSS3) font-stretch property makes text in an element narrower or more stretched out than usual.

 

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

 

Value

Description

condensed

Narrower than semi-condensed

expanded

Wider than semi-expanded

extra-condensed

Narrower than condensed

extra-expanded

Wider than expanded

normal

(default value). No adjustment applied

semi-condensed

Narrower than normal

semi-expanded

Wider than normal

ultra-condensed

Narrower than extra-condensed

ultra-expanded

Wider than extra-expanded

 

Default Value:

normal

JavaScript syntax:

e.g. object.style.fontStretch="condensed"

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;}
.x1 {font-stretch: extra-expanded;}
</style>
</head>
<body>
Note: not all browsers recognise this style<br>
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.fontStretch = "extra-expanded";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyFontStretch() {
  var x = document.createElement("DIV"); x.style.fontStretch = "extra-expanded"; return (window.getComputedStyle(x, null).fontStretch == "extra-expanded");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile