CSP: font-src
The HTTP Content-Security-Policy
(CSP)
font-src
directive specifies
valid sources for fonts loaded using @font-face
.
CSP version | 1 |
---|---|
Directive type | Fetch directive |
default-src fallback |
Yes. If this directive is absent, the user agent will look for the
default-src directive.
|
Syntax
http
Content-Security-Policy: font-src 'none';
Content-Security-Policy: font-src <source-expression-list>;
This directive may have one of the following values:
'none'
-
No resources of this type may be loaded. The single quotes are mandatory.
<source-expression-list>
-
A space-separated list of source expression values. Resources of this type may be loaded if they match any of the given source expressions.
Source expressions are specified as keyword values or URL patterns: the syntax for each source expression is given in CSP Source Values.
Examples
Violation cases
Given this CSP header:
http
Content-Security-Policy: font-src https://example.com/
The following font resource loading is blocked and won't load:
html
<style>
@font-face {
font-family: "MyFont";
src: url("/proxy/https://not-example.com/font");
}
body {
font-family: "MyFont";
}
</style>
Specifications
Specification |
---|
Content Security Policy Level 3 # directive-font-src |
Browser compatibility
BCD tables only load in the browser