Path: blob/main/files/en-us/web/css/@font-face/unicode-range/index.md
6517 views
------{{CSSRef}}
The unicode-range CSS descriptor sets the specific range of characters to be used from a font defined by {{cssxref("@font-face")}} and made available for use on the current page. If the page doesn't use any character in this range, the font is not downloaded; if it uses at least one, the whole font is downloaded.
Syntax
Values
single codepoint
: A single Unicode character code point, for example
U+26.
codepoint range
: A range of Unicode code points. So for example,
U+0025-00FFmeans include all characters in the rangeU+0025toU+00FF.
wildcard range
: A range of Unicode code points containing wildcard characters, that is using the
'?'character, so for exampleU+4??means include all characters in the rangeU+400toU+4FF.
Description
The purpose of this descriptor is to allow the font resources to be segmented so that a browser only needs to download the font resource needed for the text content of a particular page. For example, a site with many localizations could provide separate font resources for English, Greek and Japanese. For users viewing the English version of a page, the font resources for Greek and Japanese fonts wouldn't need to be downloaded, saving bandwidth.
Formal definition
{{cssinfo}}
Formal syntax
{{csssyntax}}
Examples
Using a different font for a single character
In this example we create a simple HTML containing a single {{HTMLElement("div")}} element, including an ampersand, that we want to style with a different font. To make it obvious, we will use a sans-serif font, Helvetica, for the text, and a serif font, Times New Roman, for the ampersand.
In the CSS we are in effect defining a completely separate {{cssxref("@font-face")}} that only includes a single character in it, meaning that only this character will be styled with this font. We could also have done this by wrapping the ampersand in a {{HTMLElement("span")}} and applying a different font just to that, but that is an extra element and rule set.
HTML
CSS
Result
{{EmbedLiveSample("Using_a_different_font_for_a_single_character", 500,104)}}
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
{{cssxref("@font-face/font-display", "font-display")}}
{{cssxref("@font-face/font-family", "font-family")}}
{{cssxref("@font-face/font-stretch", "font-stretch")}}
{{cssxref("@font-face/font-style", "font-style")}}
{{cssxref("@font-face/font-weight", "font-weight")}}
{{cssxref("font-feature-settings", "font-feature-settings")}}
{{cssxref("@font-face/font-variation-settings", "font-variation-settings")}}
{{cssxref("@font-face/src", "src")}}