unicode-range

CSS unicode-range Property

The Unicode-range descriptor defines the specific range of the characters that are used with fonts specified by the @font-face property for the use on the page. When @font-face is not supported, a fallback font should be included.

If the page does not use a character in the range, the font is not downloaded. If at least one character is used, the whole font is downloaded.

Unicode points are preceded by a U+ followed by up to six characters that make up the character code. Points or ranges that do not have this format are considered invalid and will make the property be ignored.

There are a lot of Unicode options to use. Basic Latin (0020—007F) is the most common range for English sites.

类目类目
Initial ValueU+0-10FFFF
Applies toThe @font-face block the property is included inside.
InheritedYes.
AnimatableNo.
VersionCSS3
DOM Syntaxobject.style.unicodeRange = “U+0025-00FF”;

Syntax

Syntax

unicode-range: single codepoint | codepoint range | wildcard range | initial | inherit;

Example of the unicode-range property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      @font-face {
        font-family: 'MyFont';/* Define the custom font name */
        src: url('myfont.woff2') format('woff2'), 
             url('myfont.woff') format('woff');/* Define where the font can be downloaded */
             unicode-range: U+00-FF;/* Define the available characters */
      }
      div {
        font-size: 3em;
        font-family: MyFont, Helvetica, sans-serif;
      }
    </style>
  </head>
  <body>
    <h2>Unicode-range property example</h2>
    <div>Mary & Jack are friends.</div>
  </body>
</html>

Values

Values

ValueDescription
single codepointA Unicode character code point which is represented in a form of one to six hexadecimal digits.
codepoint rangeA range of Unicode code points which is represented in a form of two hyphen-separated Unicode code points. It specifies the start and end of a range.
wildcard rangeA range of Unicode code points containing wildcard characters, that is using the ‘?’ character to indicate any hexadecimal digit.
initialSets the property to its default value.
inheritInherits the property from its parent element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部