Adding a Centered Title to the Header

Written by Dan Mossop

Here's how to add a piece of centered text above or below the Divi theme's main header. This is useful for adding a site title, etc.

Adding Centered Text Above the Header

If you'd like to add a centered site-wide title at the top of your Divi Theme header, here's a quick way to do it. Simply add this CSS to your site:

#main-header:before {
    content: 'My Site Title';
    float: left;
    text-align: center;
    width: 100%;
    font-size: 24pt; 
    font-family: Arial;
    font-weight: 700;
    padding: 20px 0;
    line-height: 1.3em;
    background-color: #eee;
    color: #333;
}
.et_menu_container { 
	clear: both; 
}
Just change "My Site Title" to the text you wish to display. You may also want to change the font and colors to suit your site.

Adding Centered Text Below the Header

If you'd like to add a centered site-wide title at the bottom of your Divi Theme header, here's a quick way to do it. Simply add this CSS to your site:

/* Add centered text below Divi header */
#main-header:after {
    content: 'My Site Title';
    float: left;
    text-align: center;
    width: 100%;
    font-size: 24pt; 
    font-family: Arial;
    font-weight: 700;
    padding: 20px 0;
    line-height: 1.3em;
    background-color: #eee;
}
Again change "My Site Title" to the text you wish to display, and change the font and colors to suit your site.

Styling the Centered Text on Mobiles

The code given above should make the text look okay on mobiles too. But you may wish to style the text differently on mobiles, e.g. by reducing the font size and the padding round the text. Here's how to do that:

/* Style the centered header text on mobiles */
@media only screen and (max-width: 981px) {
    #main-header:before, 
	#main-header:after {
        font-size: 14pt !important;
        padding: 10px 0 !important; 
    }
}

Unlock the Full Potential of Shortcodes in Divi!

Empower your Divi site with the Divi Shortcode Enabler. This plugin allows shortcodes to run effortlessly in various Divi module fields, enhancing functionality and customization across your site. Perfect for adding dynamic headers or additional site elements with ease.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

3 Comments

  1. I have purchase divi booster from you years before. I appreciate the plug in and the work you have put into it.
    i added this code from above…
    /* Add centered text above Divi header */
    #main-header:before {
    content: 'My Site Title';
    float: left;
    text-align: center;
    width: 100%;
    font-size: 24pt;
    font-family: Arial;
    font-weight: 700;
    padding: 20px 0;
    line-height: 1.3em;
    background-color: #eee;
    }
    .et_menu_container { clear: both; }
    I was able to change the background color but unable to change the font color (its gray)
    Please help.
    Thank You

    Reply
    • Thanks James! You should be able to do it by adding a "color" property. I've updated the post to illustrate this – see the line that reads "color: #333;". Note that #333 is grey – you'd need to change this to your own hex color (e.g. "color: #f00;" for red). That should do it, but if not, try changing the line to "color: #f00 !important;" to help override any other styles you might have on the page which are conflicting with these ones. Hope it helps.

      Reply
      • Thank you I will give it a try

        Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest From Divi Booster

Enable Automatic Looping for YouTube Videos in the Divi Video Module

Enabling automatic looping for YouTube videos in your Divi video module ensures that content plays seamlessly and continuously without interruption. This feature can enhance user engagement, highlight key information, or create dynamic visual effects on your website....

Hide Video Controls in Divi Video Module

Disabling YouTube video controls in the Divi Video Module helps create a seamless, distraction-free viewing experience for your site visitors. This approach is useful when you want full control over how your video content appears and is interacted with on the page, or...

Mute YouTube Videos by Default in the Divi Video Module

In the Divi Video Module, starting your YouTube videos muted by default can create a more user-friendly browsing experience on your webpage. It is particularly beneficial for reducing distractions, enhancing visitor engagement, and providing a seamless content preview...

Autoplay Videos in Divi Video Module

Enabling videos in your Divi video module to start playing automatically can enhance both the site's design and user engagement. To ensure full compatibility with browser requirements, such as Chrome's autoplay policy, it's often necessary to start your videos muted...

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Random Divi Posts