W3cubDocs

/Web APIs

FontData: style property

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The style read-only property of the FontData interface returns the style of the font face.

This is the value used to select the style of the font you want to use, for example inside the font-style property.

Examples include:

  • UltraLight
  • Regular
  • Heavy
  • Medium Italic
  • Extrabold

Value

A string.

Examples

The following snippet will query for all available fonts, and log metadata. This could be used, for example, to populate a font-picker control.

js

async function logFontData() {
  try {
    const availableFonts = await window.queryLocalFonts();
    for (const fontData of availableFonts) {
      console.log(fontData.postscriptName);
      console.log(fontData.fullName);
      console.log(fontData.family);
      console.log(fontData.style);
    }
  } catch (err) {
    console.error(err.name, err.message);
  }
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
style 103 103 No No No No No No No No No No

© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/FontData/style