FontData: style property
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
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
Specification |
---|
Local Font Access API # ref-for-dom-fontdata-style |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
style |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.