Mosaic Builder provides extensive visual styling controls, but some designs require more precision than a settings panel can offer. You may need advanced selectors, CSS variables, pseudo-elements, animations, media queries, or styles that affect multiple elements together.
The Document CSS feature in Mosaic Editor Plus provides a professional CSS workspace directly inside the builder. You can write custom CSS, see the result on the editor canvas, associate rules with selected elements, and decide exactly where those rules should apply.
Document CSS supports three clearly separated scopes:
- Page
- Template
- Site
This gives you the flexibility to create a page-specific adjustment, style every page using a template, or establish global CSS for the entire website.
What is Document CSS?
Document CSS is an integrated CSS editor for Mosaic Builder.
It opens inside the builder and allows you to write complete CSS rules without leaving the editing interface. Unlike the Element CSS editor, which focuses on the currently selected element or class, Document CSS is designed for broader rules containing normal CSS selectors.
For example:
.hero-section {
padding-block: clamp(4rem, 8vw, 8rem);
}
.hero-section .cta-button {
transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.hero-section .cta-button:hover {
transform: translateY(-2px);
box-shadow: 0 12px 30px rgb(0 0 0 / 12%);
}
The editor supports normal CSS capabilities, including:
- Class and ID selectors
- Descendant and compound selectors
- Pseudo-classes such as
:hoverand:focus-visible - Pseudo-elements such as
::beforeand::after - CSS custom properties
var()references- Media queries
- Container queries
- Keyframe animations
- Complex responsive rules
The CSS is previewed inside the Mosaic canvas and saved through the appropriate Document CSS scope.
Why do we need Document CSS?
Visual controls are ideal for common styling tasks, but CSS remains necessary for advanced and highly customized designs.
Create styles that visual controls cannot express
Some designs require selectors or properties that are difficult to represent through individual controls.
Examples include:
.feature-card:has(.feature-card__badge) {
border-color: var(--accent-color);
}
.pricing-table > :nth-child(2) {
transform: scale(1.04);
}
.heading-highlight::after {
content: "";
position: absolute;
inset-inline: 0;
bottom: -0.25rem;
height: 0.2rem;
background: currentColor;
}
Document CSS lets advanced users implement these designs without modifying theme files.
Keep custom CSS connected to the builder
Adding CSS through an external theme file creates a disconnect between the code and the design being edited.
Document CSS keeps both in the same workspace. You can select an element, inspect its ID and classes, open the relevant selector, update the CSS, and immediately check the canvas.
Avoid unnecessary global CSS
Not every rule should load everywhere.
A unique landing-page animation should not necessarily become part of the entire site’s CSS. With Page, Template, and Site scopes, you can place each rule at the narrowest appropriate level.
This improves organization and reduces accidental styling conflicts.
Work safely with Mosaic elements
Document CSS synchronizes with Mosaic’s built-in Element ID and CSS Classes settings. It does not need to generate an additional class for every element.
That means your CSS uses selectors that are visible and manageable inside Mosaic itself.
Get useful feedback while writing CSS
The editor includes validation for common mistakes such as:
- Misspelled properties
- Invalid values
- Missing or unmatched braces
- Broken CSS syntax
An invalid line displays a small red cross in the editor gutter. The footer also shows the number of detected errors, and invalid CSS cannot be saved until the errors are corrected.
CSS custom properties such as the following are recognized correctly:
:root {
--brand-color: #2563eb;
--content-width: 74rem;
}
You can then use them without false validation errors:
.content-wrapper {
max-width: var(--content-width);
}
.primary-button {
background-color: var(--brand-color);
}
How to open Document CSS
Document CSS can be opened from two places inside Mosaic Builder.
Mosaic top toolbar
Select the CSS icon in Mosaic’s top toolbar. Hovering over it displays the native Mosaic tooltip identifying it as Document CSS.
Settings menu
Open the builder’s settings menu and select Document CSS. The link appears above the Keyboard Shortcuts menu item.
Both actions open the same editor and preserve your preferred layout.
Understanding the editor interface
The Document CSS workspace includes several tools designed for a professional editing workflow.
Scope selector
At the top of the editor, you can choose:
- Page
- Template
- Site
Each scope stores a separate stylesheet. Switching the scope changes the CSS currently displayed in the editor.
Save CSS button
Document CSS uses deliberate manual saving.
After you change the code, the status changes to Unsaved changes and the Save CSS button becomes available. Select it when you are ready to store the stylesheet.
If the editor detects an error, saving is disabled until the CSS is corrected.
Live canvas preview
Valid CSS is injected into the Mosaic preview canvas, including its iframe. This lets you check the visual result while working without needing to save and reload the frontend after every small change.
The preview is temporary until you select Save CSS.
Error diagnostics
The footer displays the current number of errors. Invalid lines receive a small red cross in the gutter.
Hovering over the marker reveals the related validation message.
CSS variable autocomplete
Document CSS recognizes custom properties defined in the available stylesheets.
Suggestions appear when you type:
var
var(
var(--
or begin defining a property:
--brand
Variables can be discovered from the Page, Template, Site, builder, and canvas stylesheets.
Editor layouts
Document CSS supports three workspace layouts.
Dock below canvas
The editor is positioned underneath the preview. This is the default layout and works well when you want a wide coding area while keeping the page visible above it.
Split view
The editor and preview appear side by side. This is useful on larger displays because the CSS and visual result remain visible simultaneously.
Full editor
The CSS editor uses the full available builder workspace. This mode is useful when writing longer stylesheets, media queries, keyframes, or complex selector structures.
The docked and split layouts can also be resized. Mosaic Editor Plus remembers the selected layout and size for future sessions.
Working with element IDs and CSS classes
When you select an element in Mosaic, Document CSS displays two fields:
- Element ID
- CSS class
These fields synchronize directly with Mosaic’s built-in element settings.
Adding an Element ID
Enter the ID without the # prefix:
pricing-section
Press Enter to apply it. Mosaic stores the value in the selected element’s native ID setting.
Document CSS displays it as a selector chip:
#pricing-section
IDs should normally be unique within the page.
Adding a CSS class
Enter the class name without the . prefix:
pricing-card
Press Enter to attach the class through Mosaic’s native CSS Classes setting.
Document CSS displays it as:
.pricing-card
Classes are reusable and are usually the better choice when multiple elements need the same styling.
Using selector chips
Selector chips provide a quick connection between the selected Mosaic element and its Document CSS rules.
Creating a rule
If a chip does not have CSS yet, select it. Document CSS inserts a new rule:
.pricing-card {
}
The cursor is placed inside the declaration block so you can start typing immediately.
Finding an existing rule
If the selector is already present, selecting its chip does not create a duplicate. Instead, the editor scrolls directly to the existing rule.
Understanding the applied state
Selector chips visually indicate whether CSS has been written for them.
- A neutral chip means that the selector has no rule or its rule is empty.
- A green chip with a small status dot means that the selector has CSS declarations in the currently selected scope.
For example:
.pricing-card {
padding: 2rem;
border-radius: 1rem;
}
The .pricing-card chip will display the applied state.
This helps you understand which classes and IDs have already been styled without searching through the complete stylesheet.
Resetting an ID or class
When an ID or class is reset through Mosaic, Document CSS can remove the related selector rule automatically.
If a class is still used by another element, its CSS is preserved. This prevents a shared class rule from being removed simply because it was detached from one element.
How to use Document CSS
A practical workflow looks like this:
- Select the element you want to style.
- Open Document CSS.
- Choose Page, Template, or Site scope.
- Add or inspect the element’s ID and CSS classes.
- Select the corresponding selector chip.
- Write your CSS inside the generated rule.
- Check the live canvas preview.
- Resolve any red error markers.
- Select Save CSS.
- Check the frontend at relevant screen sizes.
For reusable designs, prefer a class:
.feature-card {
padding: clamp(1.25rem, 2vw, 2rem);
border: 1px solid rgb(15 23 42 / 10%);
border-radius: 1rem;
background: #fff;
}
For a unique page section, an ID can be appropriate:
#homepage-hero {
min-height: min(48rem, 90vh);
}
Understanding the Page scope
Page CSS applies only to the current page or document being edited.
Use Page scope for styles that belong exclusively to one page, such as:
- A unique homepage hero
- A landing-page campaign
- A special contact-page layout
- A one-off pricing section
- Page-specific animations
- Temporary promotional styling
Example:
#black-friday-hero {
background:
radial-gradient(circle at top right, #7c3aed 0, transparent 35%),
#111827;
color: #fff;
}
#black-friday-hero .offer {
animation: offer-pulse 2s ease-in-out infinite;
}
@keyframes offer-pulse {
50% {
transform: scale(1.04);
}
}
Because the rule is stored at Page scope, it does not affect unrelated pages.
When to choose Page scope
Choose Page when the design requirement is unique to the current page and is unlikely to be reused.
Avoid placing reusable component styles here. If several pages need the same rule, Template or Site scope will be easier to maintain.
Understanding the Template scope
Template CSS applies to documents rendered with the current Mosaic template.
This scope is useful when a style belongs to a template structure rather than one specific page.
Typical uses include:
- Blog post templates
- Archive templates
- Product templates
- Header or footer templates
- Repeated landing-page templates
- Custom post type templates
- Shared template-specific responsive rules
Example:
.article-template .article-content {
max-width: 68ch;
margin-inline: auto;
}
.article-template .article-content > * + * {
margin-top: 1.25em;
}
.article-template .article-content :is(h2, h3) {
scroll-margin-top: 6rem;
}
Every document using that template can receive the same styling without duplicating the rule at Page scope.
When to choose Template scope
Choose Template when:
- The CSS belongs to the template’s structure.
- Multiple pages using the template need the rule.
- The styling should not affect other templates.
- A component behaves differently inside a particular template.
Template scope is only available when the current editor context has an applicable Mosaic template.
Understanding the Site scope
Site CSS applies globally across the website.
It is the broadest Document CSS scope and should be used for foundational rules and reusable design systems.
Good Site-scope examples include:
- Global CSS variables
- Reusable utility classes
- Shared animation definitions
- Common component classes
- Accessibility helpers
- Global typography adjustments
- Consistent focus styles
Example:
:root {
--brand-primary: #2563eb;
--brand-primary-hover: #1d4ed8;
--surface: #ffffff;
--text-primary: #0f172a;
--radius-card: 1rem;
--shadow-card: 0 12px 35px rgb(15 23 42 / 10%);
}
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.focus-ring:focus-visible {
outline: 2px solid var(--brand-primary);
outline-offset: 3px;
}
When to choose Site scope
Choose Site when the rule is intended to be reusable across different pages and templates.
Because Site CSS has the widest reach, use precise selectors and avoid broad rules that might unexpectedly affect builder elements.
For example, prefer:
.site-content .button {
border-radius: 999px;
}
over:
button {
border-radius: 999px;
}
unless every button on the site should receive that treatment.
How the three scopes work together
Document CSS combines the scopes in this order:
- Site
- Template
- Page
This means Site CSS provides the global foundation, Template CSS adds context-specific styling, and Page CSS provides the most specific document-level adjustments.
When selectors have the same specificity, a later scope can override an earlier one.
For example, Site CSS might define:
.promo-banner {
background: #eff6ff;
}
Template CSS could refine it:
.promo-banner {
padding: 2rem;
}
Page CSS could provide a page-specific override:
.promo-banner {
background: #fef3c7;
}
The resulting banner receives the Template padding and Page background.
CSS specificity still applies. A highly specific Site selector can override a less specific Page selector, even though Page CSS is loaded later. Use normal CSS cascade rules when planning overrides.
Recommended scope strategy
A maintainable project generally follows this model:
Site scope
Store design foundations and broadly reusable classes.
:root {
--section-space: clamp(4rem, 8vw, 8rem);
}
Template scope
Store structural rules associated with a specific template.
.blog-post-layout {
grid-template-columns: minmax(0, 1fr) 18rem;
}
Page scope
Store one-off modifications for the current page.
#launch-page .hero-title {
max-width: 12ch;
}
Start with the narrowest scope that accurately represents where the rule belongs. Move it to a broader scope only when it becomes reusable.
Best practices
Prefer meaningful class names
Use names that describe purpose instead of appearance.
Good:
.checkout-summary
Less maintainable:
.grey-box-right
Use IDs only for unique elements
Classes should handle most reusable styling. Reserve IDs for truly unique page landmarks or targets.
Define reusable variables at Site scope
Variables are most useful when they provide a shared design system:
:root {
--color-accent: #7c3aed;
--space-section: clamp(4rem, 10vw, 9rem);
}
Keep selectors reasonably specific
Avoid selectors that are difficult to override:
main#content .page-wrapper .section .container .button {
/* Too specific */
}
Prefer:
.hero-cta {
/* Easier to maintain */
}
Validate before saving
Resolve the red cross markers before selecting Save CSS. Hover over a marker to inspect its error message.
Test the frontend
The builder provides a close live preview, but the saved frontend should still be tested across relevant devices, states, and user roles.
Conclusion
Document CSS brings a professional coding workflow directly into Mosaic Builder.
It combines the flexibility of handwritten CSS with the convenience of visual editing:
- Live canvas preview
- Native Mosaic class and ID synchronization
- Page, Template, and Site scopes
- Selector chips with applied-state indicators
- Direct navigation to existing rules
- CSS error markers
- CSS variable support and autocomplete
- Resizable dock, split, and full-editor layouts
- Manual saving for predictable control
Whether you are creating one small page adjustment or building a reusable site-wide design system, Document CSS gives you precise control without disconnecting your code from the Mosaic editing experience.

