| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en-US/docs/Web/API/CSSFontFaceRule | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
The CSSFontFaceRule interface represents an @font-face at-rule.
Inherits properties from its ancestor CSSRule.
CSSFontFaceRule.style Read onlyReturns a CSSFontFaceDescriptors object that allows reading and setting the descriptors of the associated @font-face at-rule.
Inherits methods from its ancestor CSSRule.
This example defines a @font-face rule and then iterates over the rules on the page until the associated CSSFontFaceRule is found.
It then logs some of the properties.
@font-face {
font-family: "MyHelvetica";
src:
local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"),
url("MgOpenModernaBold.woff2");
font-weight: bold;
}
#log {
height: 200px;
overflow: scroll;
padding: 0.5rem;
border: 1px solid black;
}
<pre id="log"></pre>
const logElement = document.querySelector("#log");
function log(text) {
logElement.innerText = `${logElement.innerText}${text}\n`;
logElement.scrollTop = logElement.scrollHeight;
}
const myRules = document.getElementById("css-output").sheet.cssRules;
for (const rule of myRules) {
if (rule instanceof CSSFontFaceRule) {
log(`this: ${rule}`);
log(` cssText: ${rule.cssText}`);
log(` parentRule: ${rule.parentRule}`);
log(` parentStyleSheet: ${rule.parentStyleSheet}`);
log(` type: ${rule.type}`);
log(` style: ${rule.style}`);
}
}
| Specification |
|---|
| CSS Fonts Module Level 4 # om-fontface |
This page was last modified on Apr 17, 2026 by MDN contributors.
CSSFontFaceRuleCSSCSSConditionRuleCSSFontFeatureValuesMapCSSFontFeatureValuesRuleCSSFontPaletteValuesRuleCSSFunctionDeclarationsCSSFunctionDescriptorsCSSFunctionRuleCSSGroupingRuleCSSImportRuleCSSKeyframeRuleCSSKeyframesRuleCSSLayerBlockRuleCSSLayerStatementRuleCSSMediaRuleCSSNamespaceRuleCSSPageDescriptorsCSSPageRuleCSSPropertyRuleCSSRuleCSSRuleListCSSStartingStyleRuleCSSStyleDeclarationCSSStylePropertiesCSSStyleRuleCSSStyleSheetCSSSupportsRuleCaretPositionMediaListMediaQueryListScreenStyleSheetStyleSheetListYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |