π Introduction
The font-stretch property in CSS allows you to control the horizontal width of text. It works by selecting a condensed or expanded version of a typefaceβif available. This property is especially useful when designing headings, logos, or interfaces that need tight or wide typography. β¨
π What is font-stretch?
The font-stretch property adjusts how wide or narrow the text characters appear. It does not scale the text visually; instead, it selects a font face that is naturally narrower or wider.
Basic Usage
p {
font-stretch: expanded;
}π Available Values
font-stretch supports both keyword values and percentage values.
β¨ Keyword Values
- πΉ ultra-condensed
- πΉ extra-condensed
- πΉ condensed
- πΉ semi-condensed
- πΉ normal (default)
- πΉ semi-expanded
- πΉ expanded
- πΉ extra-expanded
- πΉ ultra-expanded
π Percentage Values (50%β200%)
Percentage values give more precise control.100% = normal width. Lower values = narrower text. Higher values = wider text.
Percentage Example
h1 {
font-stretch: 150%; /* wider text */
}
p {
font-stretch: 80%; /* narrower text */
}Note
π Comparison Table
| Value | Stretch Level | Description |
|---|---|---|
| ultra-condensed | Very narrow | Tightest character width |
| condensed | Narrow | Compact headings |
| normal | Default | Standard width |
| expanded | Wide | Better spacing for titles |
| ultra-expanded | Very wide | Extra spacing effect |
π§ How It Works Behind the Scenes
Many fonts come with multiple widths like:Condensed, Expanded, and Semi-expanded. When you apply font-stretch, the browser chooses the closest matching font variant.
Note
font-stretch.π₯ Using Variable Fonts (Best Modern Approach)
Variable fonts offer continuous control over width, making font-stretch extremely powerful.
Variable Font Example
@font-face {
font-family: "RobotoFlex";
src: url("RobotoFlex-VariableFont.woff2") format("woff2-variations");
font-stretch: 50% 200%;
}
h1 {
font-family: "RobotoFlex";
font-stretch: 170%;
}πΈ Visual Demonstration
Further details can be found at: https://dummyimage.com/900x250/ccc/000&text=Condensed+vs+Normal+vs+Expanded
π Real-World Example
Use in Headings and Labels
.title {
font-weight: 700;
font-stretch: semi-expanded;
}
.menu-text {
font-stretch: condensed;
}
.logo {
font-stretch: 180%;
letter-spacing: 1px;
}π‘ Best Practices
- βοΈ Use condensed for tight UI and navigation menus.
- βοΈ Use expanded styles for bold titles and hero sections.
- βοΈ Use percentage values for fine control in variable fonts.
- βοΈ Avoid extreme stretching for paragraphsβit reduces readability.
- βοΈ Always confirm that the font supports stretch variations.
π Conclusion
The font-stretch property gives you control over how wide or narrow your text appears. Whether using keyword options or leveraging the power of variable fonts, understanding font-stretch helps you create modern, flexible typography for the web. π