The Code Module is a blank canvas that allows you to add code to your page, such as plugin shortcodes or static HTML code. If you want to use a third-party plugin, for example a third-party slider plugin, you can simply place the plugin's shortcode in a standard or fullwidth code module to display the element unfettered.

How to add a code module to your page

Before you can add a code module to your page, you must first access the Divi Builder. Once the Divi theme installed on your Website, you will notice a button Use Divi Builder above the publisher each time you create a new page.

By clicking on this button, you activate Divi Builder, which gives you access to all the Divi Builder modules. Then click on the button Use Visual Builder to start the generator in visual mode.

You can also click on the button Use Visual Builder when you browse your Website upstream if you are logged into your WordPress dashboard.

button divi builder module blog divi

Once entered into Visual Builder, you can click the gray plus button to add a new module to your page. New modules can only be added inside rows. If you are starting a new page, remember to add a row to your page first.

Insert the divi code module

 

Locate the code module in the list of modules and click on it to add it to your page. The list of modules is searchable, which means you can also type the word "code" and then hit enter to automatically find and add the code module! Once the module is added, you will be greeted with the list of module options. These options are separated into three main groups: Contents , Design et Advanced .

Use case by adding a dull stylesheet to animate content on an individual page

In this example, I'll add a link script to import Animate.css to add animation effects to the elements on the page. Since the Animate.css file contains a lot of code, it makes sense to only load it on the page that I need.

Just add a regular section and a full-width line (1 column) and add the code module.

Divi builder code

In the text box of contents, add the code snippet.

Add the animate.css snippet

All you have to do is add a few CSS classes to animate any element of your CSS class page on your page. In this example, I'm going to bounce the button when the page loads.

In the Button module settings, on the Advanced tab, enter the two classes "animated" and "bounce" in the CSS class text box.

Add a css animate class

Now the button bounces when the page loads.

Animation of the divi builder button

Tip: Sometimes adding code with line breaks will cause the code to stop working. It is best to create your code in a text editor and paste it into the code module.

Code content options

In the tab of contents, you will find all the content elements of the module, such as text, images and icons. Everything that controls what appears in your module will always be in this tab.

Divi builder code parametersContents

Here you can place any HTML, CSS, or JavaScript code that you want to display on the page at the current location. Only editors and admins are allowed to post unfiltered HTML, which means code may be removed from the course if used by an author or contributor. You can also place shortcodes in the module. These course codes (shortcodes) will be displayed inside the parent column without any additional Divi module wrappers.

Administration Label

This will change the module label in the generator for easy identification. When using the WireFrame view in Visual Builder, these labels will appear in the module block of the Divi Builder interface.

Code design options

In the Design tab, you will find all the module styling options, such as fonts, colors, size and spacing. This tab allows you to modify the appearance of your module. Each Divi module has a long list of design settings that you can use to tweak just about anything.

Design option module code divi builderMaximum width

Any value entered here limits the width of any content rendered in the code module to the set value. For example, entering 50% in the input field will reduce the contents of the code module to 50% of the column that contains it.

Code Advanced Options Code

On the Advanced tab, you'll find options that more experienced web designers may find useful, such as custom CSS and HTML attributes. Here you can apply custom CSS to any of the module's many elements. You can also apply custom CSS classes and IDs to the module, which can be used to customize the module in your child theme's style.css file.

Section advance module code divi builder

CSS ID

Enter an easy to use CSS ID for this module. An ID can be used to create a custom CSS style or to link to particular sections of your page.

CSS class

Enter the optional CSS classes to use for this module. A CSS class can be used to create custom CSS styling. You can add multiple classes, separated by a space. These classes can be used in your Divi theme Child or in the custom CSS that you add to your page or your Website using Divi theme options or Divi Builder page settings.

Custom CSS

Custom CSS can also be applied to the module and any of the module's internal elements. In the Custom CSS section, you will find a text field where you can add CSS directly to each element. The CSS entries in these settings are already embedded with style tags. So you just have to enter CSS rules separated by semicolons.

Visibility

This option allows you to control the devices on which your module appears. You can choose to deactivate your module on tablets, smartphones or desktops individually. This is useful if you want to use different modules on different devices or if you want to simplify the mobile design by eliminating certain elements from the page.

That's it for this tutorial.