@document CSS At-Rule

Deprecated: This feature is no longer recommended.


The @document CSS at-rule sets rules based on the address of the document. For example, if the addresses of the mobile and the main version of the site are different, then we can set our own style of elements for each version.


@document [ <url> | url-prefix(<string>) | domain(<string>) | media-document(<string>) | regexp(<string>) ]# {


  • url()Specifies the exact address of the page for which style rules apply. The address is written inside the url () brackets.
  • url-prefix()The value at which the address of the document begins.
  • domain()The domain or subdomain of the site.
  • regexp()The regular expression to which the address matches.


@document url("http://www.example.com/widgets/") {
body {
color: #FFF;
background: #800;

Browser Support

The following table will show you the current browser support for the at-rule @document.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 30th September 2023