CSS Usage of font-stretch
Property
The font-stretch
property is useful when working with variable fonts that support width variations. Here’s how you can use it in different scenarios.
1. Basic Usage
✅ This makes the paragraph text appear narrower than the default font width.
2. Using Different Stretch Values
✅ h1
will have a wider text appearance, while h2
will be slightly narrower.
3. Using Percentage Values
✅ This stretches the font width to 120% of its normal width.
4. Animating font-stretch
You can animate font-stretch
for smooth transitions.
✅ The heading will expand and contract continuously.
5. Responsive Font Stretching (Media Query Example)
✅ On small screens, the text width will automatically adjust to fit the screen better.
🛑 Important Notes
- Not all fonts support
font-stretch
, so test before using. - Doesn't work in Internet Explorer (IE).
- Works best with variable fonts that have width variations.