Custom CSS: what is allowed and safe mode
The "Custom CSS" field on the Website Kit settings page lets you add your own style rules. They are linked after the generated theme and only on public pages, never in the Desk, and the settings page is in the Desk and does not load Custom CSS.
The check reads the text the way a browser does, decodes escaped characters and rejects what it does not understand. The text is never repaired automatically. The check runs in the editor while you type (a separate client twin gives the same messages) and again on the server on every save. The server does not trust the twin.
What is rejected
A save with errors is not possible. Each error is named as line:column: reason.
| In the CSS | Result |
|---|---|
@import url('base.css'); | rejected: the @import at-rule is not allowed |
.wk-card{background:url(https://example.com/a.png)} | rejected: only /files/ and /assets/ paths and small data:image/ pictures are allowed |
.modal{display:none} | rejected: the selector could match the Desk or the system UI |
a:has(img){color:red} | rejected: :has() is not allowed |
.a{width:expression(alert(1))} | rejected: expression() is not allowed |
.a{background:var(--wk-color-bg)} | rejected: var() is not allowed in properties that can load an address |
.a{--foo:1px} | rejected: custom properties must start with --wk- or --cx- |
.a{.b{color:red}} | rejected: nested rules are not allowed |
@keyframes spin{...} | rejected: the name must start with cx- |
The full limits:
- at most 32 KB, 1500 rules and block depth 3; no control or invisible characters; no
<and no-->; - of the at-rules,
@media(width, height, orientation,prefers-color-scheme,prefers-reduced-motion,screen,print),@supports,@font-face(local sources only) and@keyframesnamedcx-...are allowed; the rest,@importincluded, is rejected; url()andimage-set()only to/files/or/assets/of the same site, or to adata:image/of at most 4 KB, and only in background, list-style andborder-imageproperties;- pseudo-classes from a list;
:has()is not on it.
An example that passes the check:
.wk-card { border-radius: 12px; }
@media (max-width: 600px) { .wk-button { font-size: 18px; } }
.wk-card { padding: 16px; }
Warnings
Warnings do not block a save. They are given for: !important outside --wk- properties; text and background below 4.5:1 in one rule; a rule that hides one of the hooks of the page (wk-contact-form, wk-footer-legal, wk-price, wk-cart, wk-login-link) with display:none, visibility:hidden, opacity:0, a font under 12 px or zero height; and --wk- names and wk- classes that this version of the app does not know.
Valid CSS can still make a page awkward to use. The draft, safe mode and versions exist for that.
Draft
"Save as draft" writes a private file. A logged-in Website Manager sees the draft on the real pages at the address with ?wk_preview=1; other visitors do not (such pages are not cached and are closed to indexing). "Save" on the settings page publishes the form values and drops the draft. The draft is also dropped when the kit is updated.
Safe mode
The address with ?wk_safe=1 shows the public pages to a Website Manager with the theme layer only and no Custom CSS. A cookie keeps the mode for 8 hours, and ?wk_safe=0 leaves it. It is a view, not a fix: to fix the problem, change the CSS and save. A visitor cannot switch the mode on. The settings page has the buttons "View without Custom CSS" and "Leave safe mode".
Versions and resets
- The page keeps the last 20 looks: author, time, theme, values, Custom CSS.
- "Restore a version", "Reset Custom CSS" and "Reset to preset" each save a new version, so the last version before a restore or a reset stays in the list (the last 20 are kept).
- The settings page lives in the Desk, outside the Custom CSS, so Custom CSS does not apply to it.
After an app update
After an update the stored CSS is checked again. If the new rules reject it, the site goes back to the theme without Custom CSS, and the notes on the settings page say why. The stored text is not changed or deleted: fix it and save.
Switching it off for a site
The platform operator can switch Custom CSS off for a single site. The CSS is then saved but not applied.
More in the documentation and the articles: Website Kit features, How to install Website Kit and choose a theme.