CSS font-stretch Property

You are Here:

CSS font-stretch Property

CSS font-stretch property allows you to make text wider or narrower.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> p:nth-child(2){ font-stretch: condensed; color: red; } p:nth-child(3){ font-stretch: expanded; color: blue; } </style> </head> <body> <h1>CSS font-stretch Property</h1> <p>This is a paragraph</p> <p>This is a paragraph</p> </body> </html>

Syntax

Using CSS

element{ font-stretch: condensed; }

Using Javascript

object.style.fontStretch="condensed";

Animatable

Yes, font-stretch property is animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS font-stretch property is normal.

Property Value

The following table provides a list of values for CSS font-stretch property.

ValueExplanation
ultra-condensedCondensed the content to 50%.
extra-condensedCondensed the content to 62.5%.
condensedCondensed the content to 75%.
semi-condensedCondensed the content to 87.5%.
normalNo effect to the content (100%).
semi-expandedExpand the content to 112.5%.
expandedExpand the content to 125%.
extra-expandedExpand the content to 150%.
ultra-expandedExpand the content to 200%.

Using JavaScript

In the following example, we will demonstrate how to change the CSS font-stretch property of an element using JavaScript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> p{ font-stretch: condensed; } </style> </head> <body> <h1>CSS font-stretch Property</h1> <p>This is a paragraph.</p> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("p")[0]; function myFunction(){ x.style.fontStretch = "expanded"; } </script> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author