-
andytlaird
Hi GenerateSupport team,
I’m trying to get better with CSS so I can create small design touches on my site, like custom highlights or shapes around text. For example, I’ve been working with a class that creates a hand drawn circle effect around words using CSS as below:
/*Hand Drawn Circle */
.hand-drawn-circle {
position: relative;
display: inline-block;
padding: 0 10px; /* Adds space inside the circle */
margin: 0 5px; /* Adds space outside to keep it off other words */
}.hand-drawn-circle::after {
content: ”;
position: absolute;
top: -5px;
left: -2px;
right: -2px;
bottom: -2px;
border: 3px solid #0198de;
border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; /* Creates the oval shape */
pointer-events: none; /* Makes sure you can still click text if needed */
}What I’m a bit stuck on is how to actually apply this properly in the editor. From what I understand, I need to switch from the Visual Editor to the Code Editor, then manually find the text and wrap it with the class. But honestly, it’s pretty tricky to locate the exact words in the code view, especially on longer pages.Please see attached
Perhaps I’ve missed something, but is this the correct approach, or is there an easier way to apply a custom CSS class to specific text? Maybe there’s a way to do this directly in the Visual Editor?
Would really appreciate your professional guidance here.
Thanks a lot,
Andy -
Hi there,
or is there an easier way to apply a custom CSS class to specific text?
Yes, WP has the additional CSS class(es) field for every block in the advanced panel. You can add the class to the text block.
-
andytlaird
Hi Ying
So if I have a sentence of 7 words but I want to add the css (as the one I sent) to only 2 words how do I implement this?
-
George
Hello,
First, edit the text block as HTML.

Then, enclose the words you want with a span element including your class, like so.

Then, click the Edit Visually button again.
-
andytlaird
Thanks George I did this but wondered if there was another way – when I go to edit HTML there is so much code I cannot find the text to add the class. But if this is the only way then I’ve just gotta be patience and find it 🤣
-
George
Hi,
You can also do the following:
1. Select the text you want from the editor and highlight it from the toolbar.

2. For text color, select the same color that the text has.
Then, you CSS can become:
/*Hand Drawn Circle */ mark { position: relative; display: inline-block; padding: 0 10px; /* Adds space inside the circle */ margin: 0 5px; /* Adds space outside to keep it off other words */ } mark::after { content: ”; position: absolute; top: -5px; left: -2px; right: -2px; bottom: -2px; border: 3px solid #0198de; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; /* Creates the oval shape */ pointer-events: none; /* Makes sure you can still click text if needed */ }Every time, you highlight some text this way, the CSS will be applied to that text.
-
andytlaird
Hi George,
if I can get this to work it’s a game changer. However I’m struggling a little. In the screen shot (link below) you’ll see the circled word. Also when I go to highlight I get this also in the link below. I know you guys are busy but if you have a little more time for some more instructions ☺️
-
George
Hi, I am not sure why you get two icons there. Just select the first highlight icon and choose the color that the font has.
-
andytlaird
OK so I highlighted the text white. Then I chose another word > highlighted the text white but nothing happened. What an I doing wrong?
-
George
Hello,
Can we see a URL?
-
andytlaird
Ouch – it’s on a local server. What I can do is try to complete as much as possible – upload the website – then I can send the Url
-
George
Hi,
Yes, if you can upload to a staging environment so we could have a look and possibly login, that would be great!
-
andytlaird
Ok George please bear with me and thank you
-
andytlaird
This maybe the best solution which I didn’t know I could do!
To find words fast in the WordPress HTML Editor I can use the keyboard shortcut:
When I’m inside the HTML editor, I can hit Cmd + F on my Mac. This opens a search bar right at the top of my editor where I can type the word I’m looking for – it’ll highlight every instance and I can then add the css class.
As I have different css styles such as dashed boxes, circled words this maybe the best and now easy option?
-
George
Hi,
No, if you have multiple styles, this will not work as the highlight only adds the
markmarkup that you can edit. You would need to enclose the necessary words with a span markup and assign a class that you then reference in your CSS. -
andytlaird
I fully understand now George and thank you
- You must be logged in to reply to this topic.