CSSFontFaceRule.style

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

styleCSSFontFaceRule インターフェイスの読み取り専用プロパティで、この @font-face アットルールからスタイル情報を返します。これは CSSStyleDeclaration オブジェクトの形です。

この例では、 @font-face ページに例として挙げられている CSS を使用しています。最初に返される CSSRuleCSSFontFaceRule となります。 style プロパティは CSSStyleDeclaration を返し、fontFamily, fontWeight, src プロパティにはルールの情報が現れます。

css
@font-face {
  font-family: MyHelvetica;
  src:
    local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"),
    url(MgOpenModernaBold.ttf);
  font-weight: bold;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].style); //a CSSStyleDeclaration

仕様書

Specification
CSS Fonts Module Level 4
# dom-cssfontfacerule-style

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
style

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support