font-stretch

The font-stretch property in CSS allows you to adjust the width of characters in a text element. It’s useful for creating different visual effects or accommodating specific design requirements.

Understanding font-stretch Values

There are two primary ways to set the font-stretch property:

  1. Keywords: These provide predefined levels of stretching or condensing.
    • normal: Default width.
    • semi-condensed: Slightly narrower than normal.
    • condensed: Narrower than normal.
    • extra-condensed: Significantly narrower than normal.
    • ultra-condensed: Extremely narrow.
    • semi-expanded: Slightly wider than normal.
    • expanded: Wider than normal.
    • extra-expanded: Significantly wider than normal.
    • ultra-expanded: Extremely wide.
  2. Percentages: This offers more granular control over the character width.
    • A value between 50% and 200% can be used.
    • 100% is equivalent to normal.

Using font-stretch in CSS

Here’s a basic example:

p {
  font-family: Arial, sans-serif;
  font-stretch: condensed;
}

This will apply a condensed font style to all text within <p> elements.

Important Considerations

  • Font Support: Not all fonts support font-stretch. If the font doesn’t have variations for condensed or expanded styles, the property will have no effect.
  • Browser Compatibility: While widely supported, there might be minor differences in rendering between browsers.
  • Design Context: Use font-stretch judiciously. Excessive stretching or condensing can impact readability.

Example with Percentages

h1 {
  font-family: Arial, sans-serif;
  font-stretch: 150%;
}

This will make the heading text 50% wider than the default.

Additional Tips

  • Combine font-stretch with other font properties like font-weight and font-size for more complex typographic effects.
  • Test your styles across different browsers and devices to ensure consistent results.

By understanding and effectively using the font-stretch property, you can enhance the visual appeal and readability of your web content.