How to Highlight Text in CSS [and Some Amazing Examples]

Luke Embrey Avatar

Follow on Twitter

In this article, we will learn about CSS highlight text effects and create cool aesthetics to make certain words and sentences stand out.

Highlight text (CSS) is used for links, to make them more visible, for important words to draw attention to them and for other uses like the most copied or Tweeted text, an easy way to show which text is the most popular.

In real life, you would use a range of highlighter pens, but in web development, we will be using HTML and CSS.

Highlight Text With Pure CSS

How Do I Highlight Text In CSS?

To Highlight text in HTML you have to use an inline element such as the <span> element and apply a specific background style on it. This will create the highlighting effect, which you can tweak in many different ways to create different looks.

Most of the examples in this article follow the following structure:

<p>
    Normal Text vs <span class=”highlight”>highlighted text.</span>
</p>
Code language: HTML, XML (xml)
.highlight{
    display: inline-block;
    padding: .25em 0;
    background: #FFC107;
    color: #ffffff;
}
Code language: CSS (css)

12 Awesome CSS Highlight Text Effects

Let’s dive in and see some real-world examples of cool CSS highlight text effects. You can use these examples for your website, learn from them, or get inspired!

1. Text Highlight With Yellow Color

A beautiful example of how to highlight text with a bit of style.

Notice that the highlighting is not perfectly rectangular and uses some rounded borders together with some small rotation to give it a more natural look and feel.

I find this effect especially useful for headings. Sometimes, depending on the highlighting color, we might want to also change the color of the highlighted text to something that can create more contrast with the background.

Remember the whole point of highlighting something is making it easier to read.

2. Slanting CSS Highlight Text Effect

This cool slanting CSS highlight text effect is very cool and looks appealing.

It just uses the HTML <strong> element to highlight bold text with this cool effect.

Very simple to use and comes with a nice code example to learn from.

3. Block Highlight Text (CSS)

By using an HTML span element, you can create this lovely blocked CSS highlight text effect.

You just need to apply the CSS class to your span element and then the effect is applied.

Very easy to use and creates a bold look, easily change the colors to match your style in the CSS.

4. Highlight Text With Animation On Page Load

In this example, we can see a totally different approach to the highlighting effect.

The highlight will not be present on page load instead, it will get animated on page load creating a beautiful effect that will for sure catch your visitor’s attention.

If you are looking for an animation on page load, this example is the one for you.

5. Animated CSS Text Highlighting On Hover

Static CSS highlight text effects are cool, but using some simple animation can create more engagement.

This hover effect is fantastic and makes words more interactive, which is very important.

You can even adapt this to work with a button that pops up on a word along with this effect.

Don’t miss out on these CSS button hover effects as well

6. Highlight Text With Circle Pen Animation

A cool CSS highlight text effect that makes it look like you have circled a word with a pen.

This CSS CodePen shows you how you can easily only target a single word within a sentence, inside an HTML P tag.

The CSS used here is simple enough as well, you can easily change the colors and sizing of the circle.

7. CSS Sketch Text Highlight

This example by Ion Emil shows us that highlighting can be done in many different ways.

In this case, instead of using a more traditional yellow highlighting effect, it uses a sketchy-looking highlighting effect that looks as if it was done with a pen over a piece of paper.

8. Realistic Marker Hover Highlight Effect

Made by Jeffrey, this is another cool hover effect paired with a realistic marker effect.

It uses an SVG to pull off the realistic look, but it is simple enough to use on a webpage, it will scale to any size text.

Pure CSS as well, so it is very lightweight.

You can also find cool animations with CSS Hamburger Menus as well, check out our article on that too

9. Higlight Text With Underline Transition

When we talk about highlighting text, we usually think about adding something on top of the text. However, another way to emphasize something can also be by underlying it.

So, why not, here’s a different kind of highlighting effect if you don’t mind using an underline instead.

10. Realistic Marker Effect

If you are looking for a super realistic marker effect, this one is for you.

It looks really cool and realistic as if you actually used a marker pen.

An SVG is used to pull this off and create the special edges on the highlighted text, but it is still simple enough to use and not complicated.

11. Highlight Text With Color Gradients

If you are into gradients, why not use gradient color for your highlighted text too?

This example makes use of the linear-gradient function inside background-image to generate the gradient highlight effect. Feel free to play with it and customize the gradients!

12. Multi-Coloured Overlapping Highlighting

A little more complicated, but the result is very interesting and could be just what you are looking for.

Requires use of all HTML, CSS, and JS to pull this effect off.

However, you can easily change the colors with the RGB values in the JS code.

13. Gradient Highlight Text (CSS)

A fancy way of highlighting HTML text with a cool gradient.

You can pick any gradient you like and create a sleek look for your text.

The CSS is simple, but the outcome is fantastic.

14. Big Realistic Marker Effect

Highlighting text can be a fantastic way to make certain things stand out, in this case, pricing is the example here.

If you have an important page like pricing, highlighting the text can be a sure starting way to draw attention to a specific area.

This example uses a simple SVG to get a realistic look, but the CSS is still relatively simple.

15. Border CSS Highlight Text Effect

A very simple CSS highlight text effect.

Basically, just a border around the text, using a span element to select certain parts of the text.

You can easily change the color and padding around the CSS highlight text as well.

16. Arrow CSS Highlight Text Effect

Another cool CSS highlight text effect with a different style.

Shows how you can highlight specific words inside a sentence.

Simple CSS used and just a span element with a CSS class to use it throughout a webpage.

17. Ribbon CSS Highlight Text Effect

There are many ways to highlight text using CSS, here we have a green ribbon effect that highlights a few words.

By using a different shape, it can help make your text stand out more.

The CSS is simple as well, easy to change the color or effect if needed.

18. Bonus CSS Highlight Text Effect (jQuery)

We’ve seen some amazing CSS highlight text effects and they all offer something different. They can help make certain parts of your text stand out and draw attention to something.

This bonus one was added in because it shows you how you can use jQuery to programmatically use these text effects to highlight text, check it out!

Was this page helpful?