In Divi 5 there is no separate CSS ID & Classes field any more: you add Divi CSS classes and IDs under Advanced > Attributes > Add Attribute, with the name set to class or id and your value next to it. Separate several classes with spaces, pick the right Target Element, and write the CSS once in Theme Options or a child theme. Classes you added in Divi 4 move into the new Attributes group automatically.

Divi CSS classes are the cleanest way to style a Divi site beyond the visual settings. Give a module a class, write one CSS rule, and every element with that class follows it. Change the rule later and the whole site updates.

Divi 5 moved where this happens, and that’s why so many people search for the old field and can’t find it. This guide shows where Divi CSS classes live now, how to add them, where the CSS should go, and when presets or design variables are the better tool. Everything is checked against the Elegant Themes help center as of November 2026.

If you haven’t moved to Divi 5 yet, read my Divi 5 guide first. Custom CSS that targets Divi 4 markup is one of the things to test before you switch.

What are Divi CSS classes, and when should you use them?

A CSS class is a label you put on an element so CSS can find it. Divi adds its own classes to the markup it outputs. Custom Divi CSS classes are the ones you add yourself, with names you choose, so your styles don’t depend on Divi’s internal markup.

Divi gives you several ways to style things. Each fits a different job:

ToolScopeBest for
Design settings in the moduleOne elementOne-off styling a client may edit later
Free-Form CSS with selectorOne elementA rule the visual settings can’t express
PresetsEvery element using the presetConsistent module styles managed visually
Design variablesEvery field using the variableShared colors, fonts, sizes and spacing
Custom CSS classEvery element with the class, across modulesStyles shared by different module types, or things presets can’t do
CSS IDOne unique elementAnchor links and very specific targeting

My rule: use the visual settings, presets and variables first, and reach for Divi CSS classes when the same style must apply across different module types, or when you need CSS the builder doesn’t offer, such as a custom hover effect or a sticky element.

Where did the CSS Class field go in Divi 5?

In Divi 4 every element had a CSS ID & Classes option group on the Advanced tab, with separate fields for the ID and the class. Divi 5 replaced it with a general Attributes option group, still on the Advanced tab.

Divi CSS classes in Divi 4 vs Divi 5: from the CSS ID and Classes fields to Attributes
Same tab, new option group. Classes and IDs are now attributes.
Divi 4Divi 5
WhereAdvanced > CSS ID & ClassesAdvanced > Attributes
HowType into the CSS ID or CSS Class fieldAdd Attribute, Name: class or id, Value: your name
Which element gets itThe module wrapperChosen with Target Element (usually the module)
Other attributesNot availablearia-*, data-*, role, loading, title, rel and more
Old valuesn/aMigrated automatically into Attributes

The Custom Attributes documentation confirms the migration: any class or ID added through the old CSS Class & ID option appears as items in the new Attributes group. You don’t need to re-enter them. You do need to check they still sit on the element your CSS expects.

How do you add a Divi custom CSS class?

The steps from Elegant Themes’ Attributes option group guide:

  1. Open the settings of the section, row, column or module (the gear icon, or click the element).
  2. Go to the Advanced tab and open the Attributes option group.
  3. Click + Add Attribute.
  4. Set Target Element. For most modules leave it on the module itself.
  5. In Attribute Name enter class.
  6. In Attribute Value enter the class name, without a leading dot, for example mw-card.
  7. Save, then inspect the page in your browser to confirm the class is where you expect.

To add more than one class, separate them with spaces: mw-card mw-card--featured gives the element two classes. The same documentation warns about this the other way round, too: a space between two words always makes two classes, so call to action is three classes, not one.

Target Element matters more than it looks

Target Element decides which HTML element gets the attribute. Elegant Themes’ own example sets it to the Image inside a module so the ID lands on the image, not the wrapper. If your CSS targets something inside a module, set the target to match, or write the selector to reach it from the wrapper. A class on the wrong element is the most common reason a rule “does nothing” in Divi 5.

How do you add a Divi CSS ID?

A Divi CSS ID works the same way: Add Attribute, name id, value contact. The main use is anchor links. A menu item pointing to #contact scrolls to the section with that ID.

Two rules from the documentation and from experience:

  • Use each ID once per page. IDs are for one unique element. If two sections share an ID, anchor links and scripts behave unpredictably.
  • Style with classes, not IDs. IDs are very specific in CSS, which makes them hard to override later. Keep IDs for anchors and scripts, and use Divi CSS classes for appearance.

Where should the CSS for Divi CSS classes go?

Adding the class is half the job. The CSS has to live somewhere. Divi gives you several places, and choosing well decides how easy the site is to maintain.

LocationScopeMy view
Divi > Theme Options > Custom CSSWhole siteGood default for small to medium amounts
Child theme style.cssWhole siteBest for larger sites and version control
Page Settings > Advanced > Custom CSSOne pageOnly for page-specific tweaks
Module Advanced > Custom CSS (Free-Form)One elementFor one-offs, using the selector keyword
Code module with <style> tagsWhere the module sitsAvoid for site-wide styles

The Theme Options box is the same field as Appearance > Customize > Additional CSS, so don’t paste rules into both. I explain that sync and the other settings on that screen in my guide to Divi Theme Options.

The Code module documentation says CSS there must be wrapped in <style></style> tags. It works, but site-wide styles hidden inside a module on one page are hard to find later. I only use it for a self-contained widget.

One more habit: keep the rules for all your Divi CSS classes in one place. Splitting them between Theme Options, page settings and individual modules is how a site ends up with three slightly different versions of the same button.

Divi CSS classes in practice: code examples

Here’s a simple card style shared by blurbs, text modules and images, which a single preset can’t cover because they are different module types. Add the class mw-card to each module, then put this in Theme Options > Custom CSS:

.mw-card {
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 28px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.mw-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, .08);
}

/* A second class adds a variation */
.mw-card.mw-card--featured {
  border-color: #f4844a;
}

@media (max-width: 767px) {
  .mw-card {
    padding: 20px;
  }
}

The featured version only needs a second class in the same Attribute Value field: mw-card mw-card--featured. That is the real strength of Divi CSS classes: small, stackable rules you can mix without duplicating CSS.

Using the selector keyword for one element

For a rule that only applies to one module, you don’t need a class at all. The Custom CSS options guide explains Free-Form CSS, where the keyword selector stands for the current element:

selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

selector p {
  text-transform: uppercase;
  letter-spacing: 3px;
}

The same Custom CSS group also has Module Elements fields (Before, Main Element, After, plus parts like Title or Button). Those accept CSS properties only, not full rules with selectors and braces.

Divi CSS classes vs presets vs design variables

Divi 5 added strong visual tools, so Divi CSS classes are needed less often than in Divi 4. Elegant Themes describes presets as “more than CSS classes”, because they include structural output, backend logic and scripts. The stacked and nested presets article also explains that you can apply several presets to one element, with later presets overriding earlier ones.

Choosing between Divi CSS classes, presets and design variables
A quick way to decide which Divi tool to use for a style.
  • Use a preset when all instances are the same module type and a client may edit the style visually.
  • Use a design variable for values shared everywhere: brand colors, fonts, spacing.
  • Use a custom class when the style crosses module types, needs hover or animation CSS, or must be controlled from code.

CSS variables with Divi CSS classes

You can combine both worlds. Elegant Themes’ blog shows defining your own CSS variables inside :root in Theme Options, then using var(--name) in builder fields and in your class rules:

:root {
  --mw-radius: 12px;
  --mw-space: 28px;
}

.mw-card {
  border-radius: var(--mw-radius);
  padding: var(--mw-space);
}

Don’t target the variable names Divi generates for its own design variables. The design variables documentation notes the system doesn’t use “pretty” CSS variable names because names can change. Define your own with a prefix and you stay in control.

What other attributes can you add besides class and ID?

The Attributes group isn’t only for Divi CSS classes. Per the Custom Attributes article, you can add data-*, role, aria-* and native attributes such as loading or title. Useful examples:

  • aria-label on an icon-only button, so screen readers announce what it does.
  • data-track="hero-cta" on a button, so Google Tag Manager can fire on that exact click. My guide to Google Tag Manager on WordPress shows how to use attributes like this as triggers.
  • rel="nofollow" or rel="sponsored" on a paid or untrusted link.

A data attribute is often better than a class for tracking. Classes get renamed during redesigns, while data-track exists only for tracking and nobody changes it by accident.

How should you name Divi CSS classes?

Names matter more on a site that will be edited for years. My conventions:

  • Use a short prefix such as mw- or your brand initials, so your classes never clash with Divi’s or a plugin’s.
  • Name what it is, not how it looks. mw-card survives a redesign. orange-box doesn’t.
  • Use a modifier for variations: mw-card--featured next to mw-card.
  • Lowercase and hyphens only. No spaces (they split classes) and no leading dot in the value field.
  • Don’t target generated classes with numbers in them. When you inspect a page you’ll see classes that follow the order of modules. Move a module and the number can change, so your rule silently stops working.

Keep a short list of your Divi CSS classes and what each one does in a comment at the top of the CSS. The next developer, or you in a year, will thank you.

Why isn’t my Divi CSS class working?

When Divi CSS classes seem to do nothing, I check these in order:

  1. Is the class on the page? Inspect the element. If it’s missing, the attribute wasn’t saved or the page cache is old.
  2. Is it on the right element? Check Target Element. The class may be on the wrapper while your rule targets the inner image or button.
  3. Is the selector right? A dot in the Attribute Value (.mw-card) creates a class with a dot in its name. Use the plain name.
  4. Is something more specific winning? In the browser’s styles panel, look for your rule crossed out. Increase specificity a little (for example, add a parent class you control in front of it) before reaching for !important.
  5. Is it cached? Clear your caching plugin, CDN and browser cache, then test in a private window.

Most problems are one of the first three. After a Divi 5 migration, number two is the usual suspect, because CSS written for Divi 4 often assumed a specific wrapper.

Who doesn’t need custom Divi CSS classes?

Plenty of Divi sites never need them. If you’re a business owner editing your own site, presets and design variables cover consistent styling without any CSS to maintain. Adding custom classes you don’t understand makes the site harder to edit later.

Divi CSS classes pay off for developers and agencies building reusable layouts, for sites with custom interactions, and for anyone who wants styles under version control in a child theme. If that’s you, the habits above keep the CSS small and predictable. If you’re still choosing a builder, my comparison of the best WordPress page builders covers how Divi’s approach compares.

Frequently asked questions

Where is the CSS class field in Divi 5?

Divi 5 has no separate CSS Class field. Open the element’s settings, go to Advanced, open Attributes, click Add Attribute, set the name to class and enter your class name as the value.

How do I add multiple CSS classes in Divi?

Put them in the same Attribute Value field separated by spaces, for example mw-card mw-card–featured. Every space starts a new class name.

How do I add a CSS ID in Divi 5?

Use Advanced, Attributes, Add Attribute with the name id and a unique value such as contact. Use each ID only once per page, mainly for anchor links.

Do my Divi 4 CSS classes still work in Divi 5?

Classes and IDs from the old CSS ID and Classes fields migrate automatically into the Attributes group. Check that they still sit on the element your CSS targets, because markup can differ.

Where should I put CSS for custom Divi classes?

For most sites, Divi Theme Options Custom CSS, which is the same field as the Customizer’s Additional CSS. Larger sites are better served by a child theme stylesheet.

Should I use presets or CSS classes in Divi 5?

Use presets for consistent styles within one module type that clients edit visually, and design variables for shared values. Use Divi CSS classes for styles across module types or CSS the builder doesn’t offer.

Need help with Divi CSS?

I clean up and write CSS for Divi sites, including Divi 5 migrations where old custom classes stopped working. See my Elementor and Divi service, where fixes are $15 an hour and single pages start at $79, or send me the page that isn’t behaving.