Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions files/en-us/web/css/guides/fonts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The CSS fonts module also supports variable fonts. Unlike regular fonts, where e
- {{cssxref("font-palette")}}
- {{cssxref("font-size")}}
- {{cssxref("font-size-adjust")}}
- {{cssxref("font-stretch")}}
- {{cssxref("font-width")}} and its legacy alias {{cssxref("font-stretch")}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: In such cases, don't we usually tend to remove the legacy alias pages, redirect them towards the new name pages, and then cover the legacy name in the BCD for the new name (with "alternative name") and in the page description if we need to say something more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it’s a special case: adoption and browser support for the legacy property are so big, compared to the modern one, that it’s much more practical to use the legacy one. So most of the developers (and search engines) will start looking for the font-stretch.

Only when the font-width becomes widely supported and used, should we start considering redirecting the font-stretch.

- {{cssxref("font-style")}}
- {{cssxref("font-weight")}}

Expand All @@ -48,8 +48,6 @@ The CSS fonts module also supports variable fonts. Unlike regular fonts, where e
- {{cssxref("font-variant-position")}}
- {{cssxref("font-variation-settings")}}

The specification also defines the `font-width` property, which is not yet supported by any browser.

### At-rules and descriptors

- At-rule: {{cssxref("@font-face")}}
Expand All @@ -59,7 +57,7 @@ The specification also defines the `font-width` property, which is not yet suppo
- {{cssxref("@font-face/font-display", "font-display")}}
- {{cssxref("@font-face/font-family", "font-family")}}
- {{cssxref("@font-face/font-feature-settings", "font-feature-settings")}}
- {{cssxref("@font-face/font-stretch", "font-stretch")}}
- {{cssxref("@font-face/font-width", "font-width")}} and its legacy alias {{cssxref("@font-face/font-stretch", "font-stretch")}}
- {{cssxref("@font-face/font-style", "font-style")}}
- {{cssxref("@font-face/font-variation-settings", "font-variation-settings")}}
- {{cssxref("@font-face/font-weight", "font-weight")}}
Expand All @@ -68,7 +66,7 @@ The specification also defines the `font-width` property, which is not yet suppo
- {{cssxref("@font-face/src", "src")}}
- {{cssxref("@font-face/unicode-range", "unicode-range")}}

The CSS fonts module also defines the `font-language-override`, `font-named-instance`, `font-width`, `font-size`, `subscript-position-override`, `subscript-size-override`, `superscript-position-override`, and `superscript-size-override` descriptors. Currently, no browsers support these features.
The CSS fonts module also defines the `font-language-override`, `font-named-instance`, `font-size`, `subscript-position-override`, `subscript-size-override`, `superscript-position-override`, and `superscript-size-override` descriptors. Currently, no browsers support these features.

- At-rule: {{cssxref("@font-feature-values")}}

Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/css/guides/fonts/variable_fonts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ font-stretch: 115%;
font-variation-settings: "wdth" 115;
```

Click "Play" in the code blocks below to edit the example in the MDN Playground. Edit the CSS code to play with font-width values.
Click "Play" in the code blocks below to edit the example in the MDN Playground. Edit the CSS code to play with font width values.

```html hidden live-sample___variable-fonts-width-example
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ sidebar: cssref
---

> [!NOTE]
> The `font-stretch` descriptor was renamed to `font-width` in the [CSS Fonts specification](https://drafts.csswg.org/css-fonts/#font-stretch-desc). To preserve compatibility, the specification retains `font-stretch` as an alias for the `font-width` descriptor.
> The `font-stretch` descriptor was renamed to {{cssxref("@font-face/font-width")}} in the [CSS Fonts specification](https://drafts.csswg.org/css-fonts/#font-stretch-desc). To preserve compatibility, the specification retains `font-stretch` as a legacy alias for the `font-width` descriptor.

The **`font-stretch`** [CSS](/en-US/docs/Web/CSS) descriptor allows authors to specify a normal, condensed, or expanded face for the fonts specified in the {{cssxref("@font-face")}} at-rule.

For a particular font family, authors can download various font faces which correspond to the different styles of the same font family, and then use the `font-stretch` descriptor to explicitly specify the font face's stretch. The values for the CSS descriptor is same as that of its corresponding font property.
For a particular font family, authors can download various font faces which correspond to the different styles of the same font family, and then use the `font-stretch` descriptor to explicitly specify the font face's stretch.

## Syntax

Expand All @@ -35,20 +35,20 @@ font-stretch: 75% 125%;
font-stretch: condensed ultra-condensed;
```

The `font-stretch` property is described using any one of the values listed below.
The `font-stretch` descriptor can take a single value from the list below.

### Values

- `normal`
- : Specifies a normal font face.
- : Specifies a normally condensed font face.
- `semi-condensed`, `condensed`, `extra-condensed`, `ultra-condensed`
- : Specifies a more condensed font face than normal, with ultra-condensed as the most condensed.
- : Specifies a more condensed font face than normal, with ultra-condensed being the most condensed.
- `semi-expanded`, `expanded`, `extra-expanded`, `ultra-expanded`
- : Specifies a more expanded font face than normal, with ultra-expanded as the most expanded.
- : Specifies a more expanded font face than normal, with ultra-expanded being the most expanded.
- `<percentage>`
- : A {{cssxref("&lt;percentage&gt;")}} value between 50% and 200% (inclusive). Negative values are not allowed for this property.
- : A {{cssxref("&lt;percentage&gt;")}} value between 50% and 200% (inclusive). Negative values are not allowed for this descriptor.

In earlier versions of the `font-stretch` specification, the property accepts only the nine keyword values. CSS Fonts Level 4 extends the syntax to accept a `<percentage>` value as well. This enables variable fonts to offer something more like a continuum of character widths. For TrueType or OpenType variable fonts, the "wdth" variation is used to implement varying widths.
In earlier versions of the `font-stretch` specification, the descriptor accepts only the nine keyword values. CSS Fonts Level 4 extends the syntax to accept a `<percentage>` value as well. This enables variable fonts to offer a continuous variation of character widths. For TrueType or OpenType variable fonts, the `wdth` variation is used to implement varying widths.

If the font does not provide a face that exactly matches the given value, then values less than 100% map to a narrower face, and values greater than or equal to 100% map to a wider face.

Expand Down Expand Up @@ -105,13 +105,13 @@ The table below shows the mapping between keyword values and numeric percentages

### Variable fonts

Most fonts have a particular width which corresponds to one of the keyterm values. However some fonts, called variable fonts, can support a range of stretching with more or less fine granularity, and this can give the designer a much closer degree of control over the chosen weight. For this, percentage ranges are useful.
Most fonts have a particular width that corresponds to one of the keyterm values. However, variable fonts can support a range of widths with fine granularity, giving the designer a greater degree of control over the chosen weight. For this, percentage ranges are useful.

For TrueType or OpenType variable fonts, the "wdth" variation is used to implement varying glyph widths.
For TrueType or OpenType variable fonts, the `wdth` variation is used to implement varying glyph widths.

## Accessibility

People with dyslexia and other cognitive conditions may have difficulty reading fonts that are too condensed, especially if the font has a [low contrast color ratio](/en-US/docs/Web/CSS/Reference/Properties/color#accessibility).
People with dyslexia and other cognitive conditions may have difficulty reading fonts that are too condensed, especially if the font has a [low color contrast ratio](/en-US/docs/Web/CSS/Reference/Properties/color#accessibility).

- [MDN Understanding WCAG, Guideline 1.4 explanations](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background)
- [Understanding Success Criterion 1.4.8 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-visual-presentation.html)
Expand All @@ -128,18 +128,48 @@ People with dyslexia and other cognitive conditions may have difficulty reading

### Setting a percentage range for font-stretch

The following find a local Open Sans font or import it, and allow using the font for normal, semi-condensed and semi-expanded states.
The following example uses the [League Mono](https://www.theleagueofmoveabletype.com/league-mono) font to synthesize different font families from the same font file using the `font-stretch` descriptor with different keywords and percentages.

```html
<p>League Mono</p>
<p>League Mono</p>
<p>League Mono</p>
```

```css
@font-face {
font-family: "Open Sans";
src:
local("Open Sans") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
font-stretch: 87.5% 112.5%;
font-family: "League Mono Ultra Condensed";
src: url("/shared-assets/fonts/LeagueMono-VF.ttf") format("truetype");
font-stretch: ultra-condensed; /* same as 50% */
}

@font-face {
font-family: "League Mono Normal";
src: url("/shared-assets/fonts/LeagueMono-VF.ttf") format("truetype");
font-stretch: 100%; /* same as normal */
}

@font-face {
font-family: "League Mono Ultra Expanded";
src: url("/shared-assets/fonts/LeagueMono-VF.ttf") format("truetype");
font-stretch: ultra-expanded; /* same as 200% */
}

p:nth-child(1) {
font-family: "League Mono Ultra Condensed", sans-serif;
}

p:nth-child(2) {
font-family: "League Mono Normal", sans-serif;
}

p:nth-child(3) {
font-family: "League Mono Ultra Expanded", sans-serif;
}
```

{{EmbedLiveSample("Setting font stretch percentages", "100%", 200)}}

## Specifications

{{Specifications}}
Expand All @@ -150,11 +180,12 @@ The following find a local Open Sans font or import it, and allow using the font

## See also

- {{cssxref("@font-face/font-display", "font-display")}}
- {{cssxref("@font-face/font-family", "font-family")}}
- {{cssxref("@font-face/font-weight", "font-weight")}}
- {{cssxref("@font-face/font-style", "font-style")}}
- {{cssxref("font-feature-settings", "font-feature-settings")}}
- {{cssxref("@font-face/font-variation-settings", "font-variation-settings")}}
- {{cssxref("@font-face/src", "src")}}
- Modern {{cssxref("@font-face/font-width")}} descriptor, replacing `font-stretch`
- {{cssxref("@font-face/font-display")}} descriptor
- {{cssxref("@font-face/font-family")}} descriptor
- {{cssxref("@font-face/font-weight")}} descriptor
- {{cssxref("@font-face/font-style")}} descriptor
- {{cssxref("font-feature-settings")}} descriptor
- {{cssxref("@font-face/font-variation-settings")}} descriptor
- {{cssxref("@font-face/src")}} descriptor
- {{cssxref("@font-face/unicode-range", "unicode-range")}} descriptor
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
title: font-width
slug: Web/CSS/Reference/At-rules/@font-face/font-width
page-type: css-at-rule-descriptor
browser-compat: css.at-rules.font-face.font-width
sidebar: cssref
---

The **`font-width`** [CSS](/en-US/docs/Web/CSS) descriptor allows authors to specify a normal, condensed, or expanded face for the fonts specified in the {{cssxref("@font-face")}} at-rule.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this page needs a similar note to the one you've got at the start of the font-width page to explain the relationship between the two, but probably tweaked so that it makes sense for this page.


For a particular font family, authors can download various font faces which correspond to the different styles of the same font family, and then use the `font-width` descriptor to explicitly specify the font face's width. The available `font-width` descriptor values are the same as those of the corresponding {{cssxref("font-width")}} property.

## Syntax

```css
/* Single values */
font-width: ultra-condensed;
font-width: extra-condensed;
font-width: condensed;
font-width: semi-condensed;
font-width: normal;
font-width: semi-expanded;
font-width: expanded;
font-width: extra-expanded;
font-width: ultra-expanded;
font-width: 50%;
font-width: 100%;
font-width: 200%;

/* multiple values */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* multiple values */
/* Multiple values */

For consistency with the previous comment. This needs changing on the font-stretch descriptor page too.

font-width: 75% 125%;
font-width: condensed ultra-condensed;
```

The `font-width` descriptor can take a single value from the list below.

### Values

- `normal`
- : Specifies a normally condensed font face.
- `semi-condensed`, `condensed`, `extra-condensed`, `ultra-condensed`
- : Specifies a more condensed font face than normal, with ultra-condensed being the most condensed.
- `semi-expanded`, `expanded`, `extra-expanded`, `ultra-expanded`
- : Specifies a more expanded font face than normal, with ultra-expanded being the most expanded.
- `<percentage>`
- : A {{cssxref("&lt;percentage&gt;")}} value between 50% and 200% (inclusive). Negative values are not allowed for this descriptor.

In earlier versions of the `font-width` specification, the descriptor accepts only the nine keyword values. CSS Fonts Level 4 extends the syntax to accept a `<percentage>` value as well. This enables variable fonts to offer a continuous variation of character widths. For TrueType or OpenType variable fonts, the `wdth` variation is used to implement varying widths.

If the font does not provide a face that exactly matches the given value, then values less than 100% map to a narrower face, and values greater than or equal to 100% map to a wider face.

### Keyword to numeric mapping

The table below shows the mapping between keyword values and numeric percentages:

<table class="fullwidth-table standard-table">
<thead>
<tr>
<th scope="col">Keyword</th>
<th scope="col">Percentage</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>ultra-condensed</code></td>
<td>50%</td>
</tr>
<tr>
<td><code>extra-condensed</code></td>
<td>62.5%</td>
</tr>
<tr>
<td><code>condensed</code></td>
<td>75%</td>
</tr>
<tr>
<td><code>semi-condensed</code></td>
<td>87.5%</td>
</tr>
<tr>
<td><code>normal</code></td>
<td>100%</td>
</tr>
<tr>
<td><code>semi-expanded</code></td>
<td>112.5%</td>
</tr>
<tr>
<td><code>expanded</code></td>
<td>125%</td>
</tr>
<tr>
<td><code>extra-expanded</code></td>
<td>150%</td>
</tr>
<tr>
<td><code>ultra-expanded</code></td>
<td>200%</td>
</tr>
</tbody>
</table>

### Variable fonts

Most fonts have a particular width that corresponds to one of the keyterm values. However, variable fonts can support a range of widths with fine granularity, giving the designer a greater degree of control over the chosen weight. For this, percentage ranges are useful.

For TrueType or OpenType variable fonts, the `wdth` variation is used to implement varying glyph widths.

## Accessibility

People with dyslexia and other cognitive conditions may have difficulty reading fonts that are too condensed, especially if the font has a [low color contrast ratio](/en-US/docs/Web/CSS/Reference/Properties/color#accessibility).

- [MDN Understanding WCAG, Guideline 1.4 explanations](/en-US/docs/Web/Accessibility/Guides/Understanding_WCAG/Perceivable#guideline_1.4_make_it_easier_for_users_to_see_and_hear_content_including_separating_foreground_from_background)
- [Understanding Success Criterion 1.4.8 | W3C Understanding WCAG 2.0](https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-visual-presentation.html)

## Formal definition

{{cssinfo}}

## Formal syntax

{{CSSSyntax("font-width")}}

## Examples

### Setting a percentage range for font-width
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this example be expanded so that it also incorporates font-stretch in a sensible way to provide backwards compat? If not, maybe include a note about the potential compat issues, and what to do about it.


The following example uses the [League Mono](https://www.theleagueofmoveabletype.com/league-mono) font to synthesize different font families from the same font file using the `font-width` descriptor with different keywords and percentages.

```html
<p>League Mono</p>
<p>League Mono</p>
<p>League Mono</p>
```

```css
@font-face {
font-family: "League Mono Ultra Condensed";
src: url("/shared-assets/fonts/LeagueMono-VF.ttf") format("truetype");
font-width: ultra-condensed; /* same as 50% */
}

@font-face {
font-family: "League Mono Normal";
src: url("/shared-assets/fonts/LeagueMono-VF.ttf") format("truetype");
font-width: 100%; /* same as normal */
}

@font-face {
font-family: "League Mono Ultra Expanded";
src: url("/shared-assets/fonts/LeagueMono-VF.ttf") format("truetype");
font-width: ultra-expanded; /* same as 200% */
}

p:nth-child(1) {
font-family: "League Mono Ultra Condensed", sans-serif;
}

p:nth-child(2) {
font-family: "League Mono Normal", sans-serif;
}

p:nth-child(3) {
font-family: "League Mono Ultra Expanded", sans-serif;
}
```

{{EmbedLiveSample("Setting font width percentages", "100%", 200)}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- Legacy {{cssxref("@font-face/font-stretch")}} alias descriptor with better browser support
- {{cssxref("@font-face/font-display", "font-display")}} descriptor
- {{cssxref("@font-face/font-family", "font-family")}} descriptor
- {{cssxref("@font-face/font-weight", "font-weight")}} descriptor
- {{cssxref("@font-face/font-style", "font-style")}} descriptor
- {{cssxref("font-feature-settings", "font-feature-settings")}} property
- {{cssxref("@font-face/font-variation-settings", "font-variation-settings")}} descriptor
- {{cssxref("@font-face/src", "src")}} descriptor
- {{cssxref("@font-face/unicode-range", "unicode-range")}} descriptor
Loading