How to Create Special Text Areas with CSS in WordPress Post

Would you like to draw readers’ attention to certain text in your blog posts? One effective way to achieve this is by creating eye-catching and stylish text boxes. In this tutorial, I’ll show you how to easily create text boxes using CSS. We’ll create two classes, right_box and left_box, which will float the text boxes to the right or left.

Step 1: Creating CSS Classes

To begin, open your style sheet and add the following CSS rules for the right_box class:

.right_box {
    float: right;
    width: 200px;
    margin-left: 15px;
    border: 1px solid #FGFGFG;
    padding: 10px;
    background-color: #efefef;
}

Feel free to customize the width, margin, border color, padding, and background color to match your preferences.

Step 2: Defining the Text Box in the Post

Now that we have our CSS class, let’s proceed to create the text box within our WordPress post. Follow these steps:

  1. Switch to the HTML mode of the Text Editor.
  2. Locate the section of text you want to highlight and wrap it with a <div> element using the right_box class. For example:
<div class="right_box">
    This is the text you want to highlight.
</div>
  1. Save your post.

Step 3: Verifying the Styling

To confirm that the text is being controlled by the CSS rule, you can check the status bar at the bottom left of the Text Editor while your cursor is within the highlighted text. It should display “path: div.right_box.”

Please note that you won’t see the div tags or the box effect in Visual mode while editing the post, as it doesn’t use the theme’s style sheet. However, when you preview or publish the post, the text box will be styled according to the CSS class you defined.

I hope this tutorial helps you enhance your blog posts and capture your readers’ attention with visually appealing text boxes. Happy blogging!

Disclosure: Some of the links in this article are affiliate links and we may earn a small commission if you make a purchase, which helps us to keep delivering quality content to you. Here is our disclosure policy.

Noor Mustafa Raza
Noor Mustafa Raza
I am a WordPress Developer and Designer, author @WPArena. I am providing Free WordPress consultation and can help you to install WordPress in a secure way to small businesses and bloggers.

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Captcha verification failed!
CAPTCHA user score failed. Please contact us!

spot_img

Related Articles

Why WordPress Is The Best CMS? (And, Possible Alternatives)

Why WordPress is the best CMS? Having a website has become a necessity for both individuals and businesses. Content Management...
Read More
When optimizing the speed of your WordPress site, you might come across a performance metric known as Time to First...
Are you dealing with a broken WordPress site and don't know what to do? If your website is showing a...