CSS @swash At-Rule

The @swash at-rule assigns a custom name to an OpenType swash alternate for a font family.

It is nested inside @font-feature-values and selected using font-variant-alternates: swash().

Syntax

@font-feature-values "Decorative Font" {
  @swash {
    flourish: 1;
  }
}
.heading {
  font-family: "Decorative Font", serif;
  font-variant-alternates: swash(flourish);
}

The @swash block is nested inside @font-feature-values. Its descriptor maps a custom identifier to one positive integer representing an OpenType swash alternate index.

How @swash Works

A swash is a decorative form of a letter, often with an extended stroke or flourish. The name declared in @swash can be referenced through font-variant-alternates: swash().

The CSS rule selects an existing glyph feature; it does not draw or generate new letterforms.

OpenType Font Support

The chosen font must include the relevant OpenType swash substitutions, such as the swsh or cswh features. Not every font or character offers a swash form.

Test with a properly licensed font known to contain swash alternates. If a fallback font is used, the requested appearance may not be available.

Single Index and Named Values

@font-feature-values "Decorative Font" {
  @swash {
    flourish: 1;
    flourish-alt: 2;
  }
}

Each named @swash value takes one positive integer. The custom names are author-defined and must match the names passed to swash().

Typography and Readability

Swashes are best suited to short display text, such as headings, logos, or invitations. Extensive decorative letterforms can make paragraphs harder to read.

Keep meaningful text accessible in its normal characters. A missing swash feature should never hide important information.

Fallback Behavior

.heading {
  font-family: "Decorative Font", serif;
  font-variant-alternates: normal;
}
@supports (font-variant-alternates: swash(flourish)) {
  .heading {
    font-variant-alternates: swash(flourish);
  }
}

Normal glyphs remain a readable fallback when the font or browser cannot apply the alternate. The feature query checks CSS syntax, not whether a particular font has the glyph.

@swash Example

This example defines and applies a named swash. Replace the placeholder font with a font that actually contains the requested glyph feature.

HTML

<h2 class="heading">Sample typography</h2>

CSS

@font-feature-values "Decorative Font" {
  @swash {
    flourish: 1;
  }
}
.heading {
  font-family: "Decorative Font", serif;
  font-variant-alternates: swash(flourish);
}

Preview: The decorative result depends on the font. A Browser Result using an unspecified font would not reliably demonstrate the swash feature.

Browser Support

Support for @font-feature-values, @swash, and font-variant-alternates varies by browser and version. Check Can I Use? and test with the actual OpenType font.

Specifications

@swash is described in CSS Fonts Module Level 4.

CSS Fonts Module Level 4