Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 37 ยท Layout and Design

Classes and the Box Model in Webflow

Learn Webflow's core ideas: styling with reusable classes, combo classes, inheritance and states, plus margin, padding and sizing, with a runnable stand-in that simulates class styles.

If you learn only one thing about Webflow, learn classes. In Webflow you rarely style an element directly. Instead you give the element a class, such as card or button, and style the class. Every element that shares the class shares the style. Change the class once and the entire site updates. This is exactly how professional CSS works, and it is what makes a Webflow project scalable instead of a pile of one-off tweaks.

This lesson explains how the Style panel relates to classes, how combo classes create variants, how inheritance and states behave, and how spacing and sizing work under the box model. A stand-in simulates class styling so you can predict what the editor would show. The stand-in is not Webflow code. It models the ideas.

One class, many elements

Suppose your site has six product cards. If you style each one separately, you must repeat your edits six times and they will drift apart. With a class:

  1. Select the first card div.
  2. In the Style panel's class field, type card and press Enter. This creates the class and attaches it.
  3. Style the class: padding, background, border radius, shadow.
  4. Add the same class to the other five cards (or duplicate the first card).

When you later change the card padding, all six change. The Style panel always tells you what you are editing: the class name shown at the top is the target. If you want to edit only one element, you must deliberately do it with a different class or no class. This is the common source of "I changed one and they all changed" confusion, and it is intended behavior.

Name classes after what the thing is, not what it looks like: card, section-header, button. A class named blue-box becomes a lie when the brand color changes.

Combo classes: variants without duplication

A combo class is a second class stacked on top of a base class on the same element. It overrides only the properties it sets. Imagine a button class and a variant is-secondary:

TEXT
Element classes:  button  is-secondary

The element gets everything defined on button, then is-secondary changes what it needs to change (for example, the background and text color). A popular naming convention prefixes combo classes with is- (such as is-large, is-secondary) so they are easy to recognise. Be careful: a combo class applies only together with its base in the style rules, and changing the base class changes every variant.

A good rule: use combo classes for small variations of a component. If a variation needs a completely different layout, create a new base class instead.

Inheritance and the indicators

Some properties inherit from the parent: text color, font family, font size, line height. Others do not: margin, padding, border, background. If you set the font on the body, every heading and paragraph inherits it unless overridden. The Style panel displays small colored indicators beside property labels showing whether a value is set on the current class, inherited from a parent, or overridden at a different breakpoint or state. Learn what the colors mean from the hover tooltips in your Designer: they are your debugging tool.

States

Many elements have states such as hover, pressed, focused and visited links. In Webflow you pick a state from a dropdown in the Style panel and style the class while that state is active. Under the hood this becomes a pseudo-class rule like .button:hover. Always give interactive elements a visible focus style so keyboard users can see where they are.

Padding, margin, size

Recall the box model from How Websites Work. In the Style panel's Spacing section you set margin (outside) and padding (inside) with a visual box diagram you can drag. The Size section sets width, height, minimum and maximum sizes. A few practical rules:

  • Use padding to space content inside containers and margin to space siblings from each other, and stay consistent.
  • Prefer max-width with width: 100% for containers so they shrink on small screens instead of overflowing.
  • Use relative units (%, rem, vw) in places where the layout should scale and pixels where an exact size is needed.
  • Avoid fixed heights on boxes that contain text, because translated or longer text will overflow.
  • Watch margin collapse: vertical margins of adjacent blocks can combine into the larger one rather than adding up.

A mental model: the stack of classes

flowchart TB
  A["Browser defaults"] --> B["body and tag styles<br/>(inherited text properties)"]
  B --> C["Base class: card"]
  C --> D["Combo class: is-featured"]
  D --> E["State: hover"]
  E --> F["Breakpoint overrides"]
  F --> G["What the visitor sees"]

Each layer can override the one before it. A property set later in the chain wins.

Stand-in: simulating classes and combo classes

The simulation below keeps a table of class styles, applies a list of classes to an element in order, and prints the final computed style. It also reports which class supplied each property, which is the question the Style panel indicators answer.

JS Stand-in: class styles and combo classes

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Read the output from top to bottom: with only button, everything comes from the base. Adding is-secondary replaces the background and color, and adds a border. Adding is-large changes the padding again. This is why order and naming matter.

Stand-in: spotting a one-off style

A project drifts when too many elements have their own unique styling. This stand-in analyses a list of elements and flags those with unique styles, a smell that suggests a missing class.

JS Stand-in: find elements that should share a class

Press Run (or Ctrl + Enter) to see the console output here.

No output.

card-4 has 26px padding instead of 24px. That tiny difference is almost always an accident, and with a class it could not have happened.

Practical habits

  1. Create a class for every element on purpose, even if it only has one use today. Name it before styling.
  2. Style by class, not by tag, in the early stages, and keep tag styles (for h1, p) for the base typography.
  3. Use a naming system, such as section, container, card, card-title, button, is-secondary.
  4. Check the class field before you edit. Read what the panel says you are changing.
  5. Use the style manager or class cleanup tools to find unused classes before you hand over the project.

Wix comparison

In the classic Wix Editor, you style an element mostly directly, with theme-based text styles providing shared settings (headings, paragraphs). Reusable design is achieved through themes, saved designs and repeaters or components. Wix Studio works with a more class-like approach in some places: it can reuse design through components and style settings across breakpoints. The concept to keep from this lesson is simply: define the look once, reuse it everywhere. How you do that depends on the tool.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. In Webflow, what happens when you change the padding on the class 'card'?

    Styles belong to the class, so all elements that share it update together.
  2. 2. What is a combo class?

    Combo classes create variants such as is-secondary by overriding selected properties.
  3. 3. Which property type normally inherits from a parent element?

    Text properties such as font, color and line height inherit. Box properties like margin, padding and border do not.
  4. 4. Which class name is best practice?

    Name classes after their role, not their appearance, so they survive design changes.

Summary

  • In Webflow you style classes, not individual elements; the class field shows what you are editing.
  • Combo classes add variants by overriding only the properties they set.
  • Text properties inherit; box properties do not; states such as hover are styled through the state dropdown.
  • Use padding inside, margin between, and flexible sizing to keep layouts adaptable.
  • Wix reaches the same goal through themes, text styles and components.

Next: Flexbox and Grid in the Builders