How To Add Text Highlights in Divi Tutorial by Pee-Aye Creative

How To Add Text Highlights, Accents, and Underlines in Divi

Here's a fun tutorial that will help you add several different styles of highlights, accents, and underlines to text in your Divi website. Enjoy!

1. Multi-Line Text With Color Background Around Each Line

The first example of text highlights in Divi is my favorite and is fairly popular on modern websites. To create a multi-line colored background highlight like this, just add a CSS class inside the module’s Advanced Tab Custom CSS input area. In this example, we are using the class “pa-multi-line-highlight.” 

Note that we are using this with an H2 in this example, so just change the H2 in your snippet to whatever you need such as H1, p, span, etc. Copy and paste one of your choice into the Divi>Theme Options>Custom CSS box.

.pa-multi-line-highlight h2 {
  color: #ffffff;
  background-color: #e03574;
  line-height: 1.7em;
  padding-bottom: 0px;
  display: inline;
  box-shadow: 10px 0 0px 0px #e03574, -10px 0 0px 0px #e03574;
  box-decoration-break: clone;
}
<span class="pa-callout">EXAMPLE!</span>

There are two code snippets below, one for each of the examples. Copy and paste one of your choice into the Divi>Theme Options>Custom CSS box.

/*text callout 1*/
.pa-callout {
  position: relative;
  color: #ffffff;
  background-color: #2cba6c;
  font-size: inherit;
  padding: .2em .4em;
  border-radius: 6px;
  margin: 0 6px;
}
/*text callout 2*/
.pa-callout-2 {
  position: relative;
  color: #ffffff;
  background-color: #e03574;
  font-size: inherit;
  padding: .2em .4em;
  border-radius: 6px;
  margin: 0 6px 0 0;
  font-weight: bold;
}
<span class="pa-color-highlight">EXAMPLE!</span>

Copy and paste this code snippet into the Divi>Theme Options>Custom CSS box.

/*color highlights in text*/
.pa-color-highlight {
    text-decoration: none;
    box-shadow: inset 0 -.5em 0 rgba(255,166,60,0.75);
    color: inherit;
}
Change the Divi Gallery Image Aspect Ratio

Go ahead and copy and paste the CSS snippet into the Divi>Theme Options>Custom CSS box. (I added the “h2 strong” so that you could visually see it above, but you can remove that from the snippet.)

/*add highlight around bold text*/
.pa-bold-highlight p strong, h2 strong {
    padding: 0 5px;
    background-color: rgba(255,255,0,0.5);
}

Highlighted Text In General

In the comments nordie pointed out a trick to highlight text in general. This is different than what I was doing here with the bold text, but if you just want highlights, this works great!

<mark>Your highlighted text here</mark> 
81

Last updated Jan 3, 2021 @ 1:12 pm

Subscribe

Each month we send out a roundup email newsletter with the latest tutorials, product updates, helpful resources, and any other industry or personal news. Occasionally we send an extra separate email here and there if we just can’t wait! So that’s what you will get if you subscribe, and you can always unsubscribe at any time if you just can’t take it anymore :)

Please share this post!

Nelson Lee Miller (aka The Divi Teacher)

Nelson is the owner of Pee-Aye Creative in the beautiful state of Pennsylvania. He loves helping small businesses, exploring outdoors, building websites with Divi, and teaching others.

Leave A Response!

By commenting you agree to our Blog & YouTube Comments Policy

73 Comments

  1. Samson

    Cool tips! So simple and good looking. Thanks Nelson 🙂

    Reply
  2. Robyn

    Color highlights in text!

    Hi, how do I change the color on number 3 from orange to #E8ADAA?
    Thank you for these tips!

    Reply
    • Nelson Lee Miller (aka The Divi Teacher)

      Hey Robyn,
      To change the color just replace rgba(255,166,60,0.75) with your color. I used an rgb color there because it is 75% opacity, but your hex color will work perfectly too!

      Reply
      • Robyn

        Thank you so much! Still learning all this stuff! Happy holidays.

      • Mel

        Hello… great blog. I used a different hex color and changed to .6 height… and it just keeps changing back to the original… have you seen this before?

  3. Guillermo

    Cool Nelson !!!!!. Thank´s again.

    Guillermo

    Reply
  4. CHARLES KIYIMBA

    Thank you, Nelson. I am learning a lot from you here. I am so appreciative.

    Reply
  5. Peter

    Hello my friend, so nice, thank you!

    Unfortunately, I have a problem that I can’t see the highlights on my mobile device (I can’t see it even if reduce the chrome browser here on my computer to the smaller window.) Can you advise me what I’m doing wrong? Thank you!

    Reply
  6. Ezinne

    Super useful tips. Thank you so much!

    Reply
  7. Fernando

    Hi,
    I try to do this but I cant do. I use in Gutenberg editor. <span class=“pa-color-highlight”>EXAMPLE!</span> in html but not work

    Reply
  8. Lydia

    Very useful, thanks Nelson!

    Reply
  9. Paula Cabezas Alvarez

    Thanks for the tips!

    But I would like to use different colors in case number 3, not only one, I mean in different texts, for example one text with #fbf7ef and another with #eefeee. How can I do that?

    Reply
  10. Alex

    Great tips! Thank you 🙂

    Reply
  11. Chadi

    Thank you for this it’s grat. But one question How do you apply this to Meta info

    Reply
      • Chadi

        I am using this on blog titels, and I would like to extend this to the meta info under the title. Such as the date and the category and author info. Is there a way to do that as a hole, or do I have to put a seperate css for the meta.

      • Nelson Lee Miller (aka The Divi Teacher)

        The meta has a css class already, offhand I think .post-meta or something similar. So however you are targeting the title, do similar for this.

  12. brittany

    Thank you very much for the tip, they worked great. I thought it would be easy to make a specific tweak, but I’m struggling. Is it possible to use the bold as a way of changing one link to another color? I thought maybe just taking out the ‘background’ of ‘background-color’ plus a million other variations I tried. I have somehow worked myself into a complex design solution that utilizes links as a way of having 2 different sized and coloured text in one running text box, but would like just one of them to start out in a different colour. Does that make sense?

    Reply
  13. Francisco

    Excellent tutorial. How can I make that the text is centered in option number 1? It’s always justified to the left. Thanks!

    Reply
  14. nordie

    this also works
    <mark>highlight</mark> 

    Reply
  15. Emma

    Cool tips however number one keeps coming up with an expected RBRACE error – can you help?

    .pa-multi-line-highlight h2 {
    EXPECTED RBRACE
     color: #ffffff;
     background-color: #e03574;
     line-height: 1.7em;
     padding-bottom: 0px;
     display: inline;
     box-shadow: 10px 0 0px 0px #e03574, -10px 0 0px 0px #e03574;
     box-decoration-break: clone;
    }
    UNEXPECTED TOKEN ‘}’

    Reply
    • Nelson Lee Miller (aka The Divi Teacher)

      Hi Emma,
      That simply sounds like you are adding the CSS to the wrong place. Be sure to add the code to your Divi Theme Options Custom CSS or styl.css in a child theme.

      Reply
  16. pan

    i love it , thanks

    Reply
  17. Rolf

    Hi Nelson, thanks for your tips. I tried to work with No. 1 but want the text to align right. I have to lines of Text with some space in between. When I add align right to your code, I get a colored box without any space between the lines. Any ideas?

    Reply
  18. Lisa Mann

    Love this, thank you!
    I was wondering if it is possible to have every H2 in blog posts have a colorful underline. I tried the following:
    ————————
    In the Divi Builder, in the Post Content Settings I added to the CSS Class: pa-color-highlight

    In the Divi Child theme CSS I added:
    /*color highlights in text*/
    .pa-color-highlight h2 {
      text-decoration: none;
      box-shadow: inset 0 -.5em 0 rgba(136,196,221,1);
      color: inherit;
    }
    ————————-
    But, it didn’t work 🙁 Any ideas?

    Reply
    • Hemant Gaba

      Please try adding a Custom Class to the Blog Module by going to the Blog Module Settings > Advanced > CSS ID & Classes and then add a Custom CSS by grabbing that Custom Class. For example, the custom class that you have given is pa-blog-module.
      Then go to the WordPress Dashboard > Divi > Theme Options > Custom CSS Panel and place the code given below:

      .pa-blog-module article .entry-title {
      text-decoration: none;
      box-shadow: inset 0 -.5em 0 rgba(136,196,221,1);
      color: inherit;
      }

      This will highlight all the h2 tags in the blog post. Please let us know if it helps. 🙂

      Reply
      • Lisa Mann

        Thank you for the suggestion.
        To make it work I still need to manually add the class to every h2 text
        <span class=”pa-color-highlight”>TEXT</span>

        In your code, where do you state h2?

      • Hemant Gaba

        .entry-title is the class that is given to all the h2 tags in the blog module. That is why I have suggested that code and it is working completely fine for me. Please try using the code given below and if that doesn’t help then please share the URL so that I could investigate further:

        .pa-blog-module article .entry-title a{
        text-decoration: none;
        box-shadow: inset 0 -.5em 0 rgba(136,196,221,1);
        color: inherit;
        }

        Please let me know how it goes.

      • Patricia Rios

        hi thank you! What if the H2 has to lines, how can I break the underline to appear below the two lines? I found a solution with box-decoration clone, but it doesnt work! thank you!

      • Hemant Gaba

        Hey Patricia,

        Could you please share the URL of the website for me to investigate further on this?

  19. Mark Hancock

    Thank you Nelson….I am wondering….what if you already have a span style….how would that look like….

    <h1>Quality Is What <span style="color: #70bd42;">KJE Aquatics</span> Has For You</h1>
    

    Thanks,
    Mark

    Reply
    • Hemant Gaba

      If you already have a span tag and you want to highlight that then just give the class of your preferred style that is mentioned in the tutorial to the span tag and then paste the code in the Theme Options. You can change the color with the color that you want to give to your span. If you want to highlight the whole h1 then wrap that h1 tags in the span tags and then give that span a class mentioned above.

      Reply
  20. Simon

    Hi Nelson, thanks for the post, it helps a lot.

    I’m looking for a solution to move the text in the option 1 a bit above the background. The idea is to get 3 layout, 1 with a background image, the second with the text background, then the text itself.

    I did some text with text transformation and background on colomn, then offset using x/y axis. It’s working, but it’s not responsive. I tried as well with a separator, still the same issue.

    I guess I would have to use box shadow ? What do you think ?

    Thanks,

    Simon

    Reply
    • Hemant Gaba

      Hi Simon
      You need to use the Divi Responsive Functionality and set different offset values for different screens to make it responsive or else you can use the responsive units like vw, em, rem instead of pixels.

      Let us know how it goes. 🙂

      Reply
  21. Grace Glover

    Hello, thanks a lot for this. I’ve seen the highlight effect on some sites and it is really cool. Should we use a child theme, so that the CSS on the page settings are retained with subsequent Divi theme updates? Also, what’s the best place to add the CSS – is it within the page settings or theme options/custom css?

    Many thanks, I am new and still learning Divi, so any feedback greatly appreciated.

    Reply
    • Hemant Gaba

      If your CSS Code will only going to affect the elements present on a single page then you can go ahead and add the CSS in the Page Settings as it will be the best place in this scenario. If the code will going to affect more than one page then the best place to paste the code is Theme Options > Custom CSS Panel as then you will not have to place the code more than once and it will retain after the theme updates. If you want to place the code in your child theme style.css so you can as this is also equally good as the Theme options.

      Reply
  22. Carly Black

    I’m trying to get the color highlights (#3) to work and seem to be doing something wrong. I pasted the first snippet inside the CSS ID & Classes area and added the second snippet to the theme options. What am I missing?

    Reply
    • Hemant Gaba

      You need to place the first snippet under the content tab in the body text of the Module of your choice. For example, if you want to use the Text Module then add the text module and go to the Text Module Settings > Content Tab > Text and there you will see a panel (in which the dummy content will be there by default), and in that you need to place the span tag snippet. After that to place the second snippet you need to go to the WordPress Dashboard > Divi > Theme Options > Custom CSS Panel and place the code there.

      Please let us know if that helps.

      Reply
  23. Agniswar

    How to add style 3 to link text.

    Reply
    • Hemant Gaba

      In the style three, there is a span tag given. We can place the anchor tag between the span tags and provide the link to that anchor tag. Instead of just placing the span tag, place the snippet given below:

      <span class=”pa-color-highlight”><a href=”Place your link here”>EXAMPLE LINK!</a></span>

      Inside the href quotes, you need to place your link.

      Reply
  24. agniswar

    Hey Nelson
    How to make the link text effect like your blog, underline and highlight on hover.

    Reply
    • Hemant Gaba

      Place the span tag inside the text module and then place the anchor tags between the span tags to place the link as shown here: https://pasteboard.co/K4EBGvH.jpg

      Provide the custom class to the span tag. In this case, the custom class that I have given is pa-underline.
      After that go to the Divi > Theme Options > Custom CSS Panel and place the code given below:


      span.pa-underline a{
      text-decoration: underline;
      text-decoration-color: #d2007f;
      transition: all 0.2s ease-in-out;
      font-weight: bold;
      }
      span.pa-underline a:hover{
      color: #fff;
      background-color: #d2007f;
      }


      You can change the line color and the background color by changing the color value in the text-decoration-color and background-color property.

      Reply
  25. Juan Pablo Vásquez

    this blog is one of the best things that have ever happened to my life.
    true story. if you come to South America shoot me an email! You’re so welcome!

    Reply
  26. Catherine

    Hello,

    This is what I’m looking for! Thank you! but I got some problem…

    When I copy and paste the first one (Multi-Line Text With Color Background Around Each Line) to Custom CSS section, it will said “Expected RBRACE.” and “Unexpected token ‘}’.” I paste in the “Main Element” section in the Custom CSS.

    How can I fix this?

    Thank you!!

    Reply
    • Nelson Lee Miller (aka The Divi Teacher)

      Hi Catherine,
      That’s actually not the correct place for code, you should go to Divi>Theme Options in the backend and scroll down and paste it there in the Custom CSS box.

      Reply
  27. Sophie Janotta

    Hi Nelson,

    I tried the multi-line highlight and it works so far. I only have my text right aligned and with your code it is on the left. How could I have my text on the right?

    Thanks again for sharing this. Very helpful.
    Sophie

    Reply
    • Hemant Gaba

      Hey Sophie,

      I have checked the URL you provided and I am afraid that I am not able to find where you are facing the issue exactly. Could you please point me in the right direction so that I could help?

      Reply
  28. Aron

    Hi,

    I have a question to No. 2 (Text Callout). If I highlight multiple lines only the beginning and the ending of the text is rounded. (The row breaks are flat) What CSS do I have to add to make the corners rounded at the beginning and end of each row of the highlighted text?

    Reply
    • Hemant Gaba

      Hey Aron,

      Could you please share the URL for me to investigate it further?

      Reply
  29. Kristina

    Great article! Thanks for sharing.

    for highlighted body text in general, and using this:
    Your highlighted text here

    How do I change the color of the highlight?

    Thank you!

    Reply
  30. Dawna Graham

    Hi thanks for this!! I love these effects. I have a quick question: In the ‘.pa-multi-line-highlight ‘ example how would you make the text align centered? ‘text-align: center;’ doesn’t seem to do it. I’m going to keep digging around but any suggestion you have would be super helpful and appreciated! This is what I’ve got so far:
    .highlight h1 {
    color: #00303f;
    background-color: #FBC816;
    line-height: 1.6em;
    font-weight: 700;
    text-align: center;
    padding-bottom: 0px;
    display: inline;
    box-shadow: 20px 0 0px 0px #FBC816, -30px 0 0px 0px #FBC816;
    box-decoration-break: clone;
    }

    Reply
    • Hemant Gaba

      Hey Dawna,

      I have investigated the website and the text is already aligned in the center. If you can’t see the results then, please check the website in incognito mode and see if that helps.

      Reply

Submit a Comment

Your email address will not be published.

Recent Posts

Pin It on Pinterest

0

Your Cart