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.
|
One or more sources can be allowed for the
font-src
policy:
Content-Security-Policy: font-src <source>; Content-Security-Policy: font-src <source> <source>;
<source> can be one of the following:
'*'
), and you may use a wildcard (again,
'*'
) as the port number, indicating that all legal ports are valid for the source.
http://*.example.com
: Matches all attempts to load from any subdomain of example.com using the
http:
URL scheme.
mail.example.com:443
: Matches all attempts to access port 443 on mail.example.com.
https://store.example.com
: Matches all attempts to access store.example.com using
https:
.
*.example.com
: Matches all attempts to load from any subdomain of example.com using the current protocol.
http:
or
https:
. The colon is required. Unlike other values below, single quotes shouldn't be used. You can also specify data schemes (not recommended).
data:
Allows
data:
URIs
to be used as a content source.
This is insecure; an attacker can also inject arbitrary data: URIs. Use this sparingly and definitely not for scripts.
mediastream:
Allows
mediastream:
URIs
to be used as a content source.
blob:
Allows
blob:
URIs
to be used as a content source.
filesystem:
Allows
filesystem:
URIs
to be used as a content source.
'self'
blob
and
filesystem
from source directives. Sites needing to allow these content types can specify them using the Data attribute.
'unsafe-eval'
eval()
and similar methods for creating code from strings. You must include the single quotes.
'unsafe-hashes'
<script>
elements or
javascript:
URLs, this is a safer method than using the
unsafe-inline
表达式。
'unsafe-inline'
<script>
elements,
javascript:
URLs, inline event handlers, and inline
<style>
elements. The single quotes are required.
'none'
Refers to the empty set; that is, no URLs match. The single quotes are required.
'unsafe-inline'
which could still be set for older browsers without nonce support.
script-src
for external scripts.
Given this CSP header:
Content-Security-Policy: font-src https://example.com/
The following font resource loading is blocked and won't load:
<style>
@font-face {
font-family: "MyFont";
src: url("https://not-example.com/font");
}
body {
font-family: "MyFont";
}
</style>
The compatibility table in 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.
更新 GitHub 上的兼容性数据| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
font-src
|
Chrome 完整支持 25 | Edge 完整支持 14 | Firefox 完整支持 23 | IE 不支持 No | Opera 完整支持 15 | Safari 完整支持 7 | WebView Android 完整支持 Yes | Chrome Android 完整支持 Yes | Firefox Android 完整支持 23 | Opera Android ? | Safari iOS 完整支持 7 | Samsung Internet Android 完整支持 Yes |
完整支持
不支持
兼容性未知
Accept
Accept-CH
Accept-CH-Lifetime
Accept-Charset
Accept-Encoding
Accept-Language
Accept-Patch
Accept-Ranges
Access-Control-Allow-Credentials
Access-Control-Allow-Headers
Access-Control-Allow-Methods
Access-Control-Allow-Origin
Access-Control-Expose-Headers
Access-Control-Max-Age
Access-Control-Request-Headers
Access-Control-Request-Method
Age
Allow
Alt-Svc
Authorization
Cache-Control
Clear-Site-Data
Connection
Content-Disposition
Content-Encoding
Content-Language
Content-Length
Content-Location
Content-Range
Content-Security-Policy
Content-Security-Policy-Report-Only
Content-Type
Cookie
Cookie2
Cross-Origin-Embedder-Policy
Cross-Origin-Opener-Policy
Cross-Origin-Resource-Policy
DNT
DPR
Date
Device-Memory
Digest
ETag
Early-Data
Expect
Expect-CT
Expires
Feature-Policy
Forwarded
From
Host
If-Match
If-Modified-Since
If-None-Match
If-Range
If-Unmodified-Since
索引
Keep-Alive
Large-Allocation
Last-Modified
Link
Location
NEL
Origin
Pragma
Proxy-Authenticate
Proxy-Authorization
Public-Key-Pins
Public-Key-Pins-Report-Only
Range
Referer
Referrer-Policy
Retry-After
Save-Data
Sec-Fetch-Dest
Sec-Fetch-Mode
Sec-Fetch-Site
Sec-Fetch-User
Sec-WebSocket-Accept
Server
Server-Timing
Set-Cookie
Set-Cookie2
SourceMap
Strict-Transport-Security
TE
Timing-Allow-Origin
Tk
Trailer
Transfer-Encoding
Upgrade-Insecure-Requests
User-Agent
Vary
Via
WWW-Authenticate
Want-Digest
警告
X-Content-Type-Options
X-DNS-Prefetch-Control
X-Forwarded-For
X-Forwarded-Host
X-Forwarded-Proto
X-Frame-Options
X-XSS-Protection
100 Continue
101 Switching Protocols
103 Early Hints
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
300 Multiple Choices
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
307 Temporary Redirect
308 Permanent Redirect
400 Bad Request
401 Unauthorized
402 Payment Required
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Payload Too Large
414 URI Too Long
415 Unsupported Media Type
416 Range Not Satisfiable
417 Expectation Failed
418 I'm a teapot
422 Unprocessable Entity
425 Too Early
426 Upgrade Required
428 Precondition Required
429 Too Many Requests
431 Request Header Fields Too Large
451 Unavailable For Legal Reasons
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported
506 Variant Also Negotiates
507 Insufficient Storage
508 Loop Detected
510 Not Extended
511 Network Authentication Required
CSP: base-uri
CSP: block-all-mixed-content
CSP: child-src
CSP: connect-src
CSP: default-src
CSP: font-src
CSP: form-action
CSP: frame-ancestors
CSP: frame-src
CSP: img-src
CSP: manifest-src
CSP: media-src
CSP: navigate-to
CSP: object-src
CSP: plugin-types
CSP: prefetch-src
CSP: referrer
CSP: report-to
CSP: report-uri
CSP: require-sri-for
CSP: sandbox
CSP: script-src
CSP: script-src-attr
CSP: script-src-elem
CSP: style-src
CSP: style-src-attr
CSP: style-src-elem
CSP: trusted-types
CSP: upgrade-insecure-requests
CSP: worker-src