CSS And Build Rules
Read this before creating Webflow variables, classes, styles, or responsive overrides.
Native Styling Gate
- Apply styles with
data_style_tool, never with thedata_whtml_buildercssparam. WHTML CSS lands in Designer Custom properties, so the result is hard to edit and does not map to native Style-panel controls. - Bind Webflow variables with
variable_as_value: "<variable-id>"fromdata_variable_tool. Do not use rawvar(--collection---token)strings; they do not render the native variable pill. - Only truly non-native CSS belongs in Custom properties:
backdrop-filter,aspect-ratio,repeating-linear-gradientbackgrounds, parent-state selectors, custom mobile-toggle selectors, and similar CSS Webflow cannot model. - Do not use embed
<style>blocks for normal layout, typography, spacing, backgrounds, dividers, grids, cards, or section styling. That hides styling from the Designer style panel. - Do not use
::beforeor::after. Pseudo-elements are invisible in the Navigator and unselectable in Designer. Build decorative lines, grids, badges, and backgrounds as real elements with native classes.
Webflow-Compatible CSS
- Use longhand properties. Expand
padding,margin,border,border-radius,font,background,transition, andflex. - Use class selectors only. No tag, ID, descendant, or attribute selectors.
:hoveris the only safe pseudo-class in native styles. - Emit
grid-row-gapandgrid-column-gapeven on flex; Webflow stores gaps under those keys. - Build desktop-first: base styles apply to all devices, then override downward.
main: base desktopmedium: 991px and belowsmall: 767px and belowtiny: 479px and below
- Prefer flexbox. Use grid only for true two-dimensional layouts.
- Avoid unsupported/dropped values:
calc(),clamp(),min(),max(),@keyframes,@font-face, multi-layerbox-shadow, logical props, vendor prefixes. - Put inheritable typography once on
.page-wrapper: font family, color, base size, line height. Use single font names, no fallback stacks.
Design System And Units
- Follow the selected variable strategy before building sections.
- Prefer Webflow variables for repeated colors, typography, spacing, and radii unless the user explicitly selected hard-coded output.
- Follow the selected naming strategy. If using FlowKit, read/reference
webflow-mcp:flowkit-naming; otherwise use layout/structure-based kebab-case names and never page-prefixed names. - Follow the selected unit preference. Default to
px; convert toremoremonly when the user chooses that strategy.
Element Construction
- Use
data_whtml_builderfor DOM/structure only: one root element per action, markup, semantic tags, text, nesting, and class names. - To insert multiple sibling sections, use multiple WHTML actions.
- If a class does not exist, create it with
data_style_tool create_style; do not define it through WHTML CSS. - Create classes before referencing them in WHTML or element class lists. If a custom class exists only as a string in WHTML and no Webflow style exists yet, Webflow can silently drop it, leaving unstyled full-width text or broken layout.
set_stylereplaces all classes on an element. Include all intended classes when applying it.query_elementsstyle filters are case-insensitive substring matches. Filter results by exact class/type before acting.- Capture returned element ids from every insert. Re-find later by exact style/type when possible.
- Element ids are
{component, element}, wherecomponentis the page id. Use the matching top-levelpageId. - Combo classes can be ambiguous. When in doubt, prefer one standalone class with full styling.
Layout Patterns
- Use
repeating-linear-gradient, notborder-style:dashed, for dashed accents/dividers/underlines so dash length, gap, opacity, and direction match the design. - Decorative overlays must sit behind content. Make
.page-wrappera stacking context (position:relative; z-index:0) and place overlays atz-index:-1. - Never use a fixed overlay width wider than the viewport. Prefer
left:0; right:0; width:auto; max-width:<design-width>; margin-left:auto; margin-right:auto. - Replicate interior grid lines too, not just outer edges; check Figma for distributed columns.
- A fixed nav lets the first section sit under the bar; add top-padding to clear it. Sticky nav reserves space.
- Suppress Designer-only
.wf-emptyaffordances on decorative empty normal DivBlocks with a dimension-giving style in the active breakpoint. For custom-tag empty elements, add a child or use a normal DivBlock.