In-Post or -Page Highlight Boxes

by Mike Nichols · 9 comments

In some posts or pages you may want to highlight certain text by placing it within a colored box. Thesis provides a way to do this with its Note and Alert boxes. But what if you want your own colors, font styling, and borders? This guide will show you how to create and use in-post or -page highlight boxes. They are easy to implement and a great enhancement to your content!

There is only one prerequisite for this tutorial: You must know how to get to the WordPress HTML editor. If you are uncertain, see the article “How and When to Use the WordPress HTML Editor.”

How to use the Thesis Note and Alert boxes

Thesis has two highlight boxes built in, the Note and the Alert boxes. The Note box has a very light beige background, and the Alert box has a light yellow background. They are intended for highlight only one paragraph, so if you have multiple paragraphs or line breaks in your text, these are not for you.

Implementing the Note and Alert boxes is easy. Go to the HTML editor and find the text to be highlighted by a box. For the Note box, surround the the text with paragraph tags and the “note” class, as in this example:

<p class="note">This is text surrounded by the Note box.</p>

And this is how the same text looks in the Note box:

This is text surrounded by the Note box.

Using the Alert box is similar: surround the text with paragraph tags and the “alert” class, thusly:

<p class="alert">This is text surrounded by the Alert box.</p>

The same text displayed in the Alert box:

This is text surrounded by the Alert box.

How to create your own highlight boxes

But what if you want some color besides beige or light yellow, or you need to have more than one paragraph highlighted? Well, create your own highlight box!

Put the following into your custom.css file. It will create a highlight box with a cream background and a thin brown border that harmonizes with the Thesis Theme Tools color scheme. Of course, you will want to change the colors to suit your own color scheme:

/* HIGHLIGHT BOX - CREAM */
.format_text .highlight_box_cream {
	/* distance from borders to content*/
	padding: 0 1em 0 1em;
	/* spacing outside of box*/
	margin: 0 0 0 0;
	/* background color */
	background: #FEFD80;
	/* border size style color */
	border: 1px solid #B28F00;
}

Now let’s put this box into action. Go to the HTML editor and find the text to be highlighted. Surround the text with a div and the class “highlight_box_cream” like this:

<div class="highlight_box_cream">This is an example of the highlight_box_cream class highlight box.

It can cover multiple paragraphs and line breaks.</div>

Now let’s see how it looks:

This is an example of the highlight_box_cream class highlight box.

It can cover multiple paragraphs and line breaks.

Expanding the capabilities of the highlight boxes

The highlight boxes are not just limited to a colored border and background, they can have their own font characteristics and other features, too. For now, let’s confine ourselves to changing the font attributes in the box.

Put the following into your custom.css file. Note that it is the same as the highlight_box_cream class definition above, but it adds fonts to the mix. The font will be Georgia, a bit smaller than normal type, and will be in small caps. I have left other properties set to normal to keep the appearance from being too bizarre:

/* HIGHLIGHT BOX - CREAM WITH FONTS */
.format_text .highlight_box_cream_fonts {
	/* font size */
	font-size: .9em;
	/* font family */
	font-family: Georgia,"Times New Roman",serif ;
	/* font style: normal, italic etc */
	font-style: normal;
	/* font variant: small caps etc */
	font-variant: small-caps;
	/* font weight: bold etc */
	font-weight: normal;
	/* distance from borders to content*/
	padding: 0 1em 0 1em;
	/* spacing outside of box*/
	margin: 0 0 0 0;
	/* background color */
	background: #FEFD80;
	/* border size style color */
	border: 1px solid #B28F00;
}

Once again, we’ll enter the HTML editor, find the text, and surround it with a div. But this time the class will be “highlight_box_cream_fonts.”

<div class"highlight_box_cream_fonts">This is an example of the highlight_box_cream_fonts class highlight box.

Note that it is in Georgia font that is slightly smaller than normal, and uses the font variant small caps.</div>

And here is how it looks:

This is an example of the highlight_box_cream_fonts class highlight box.

Note that it is in Georgia font that is slightly smaller than normal, and uses the font variant small caps.

The bottom line

There are several other things you can do to the highlight boxes. You can add an image for a background. You can even eliminate the borders and background and use it to alter text in your post or page. The principles of usage are the same, whatever you do with it.

I hope this tutorial has been useful to you. Remember that your comments are always welcome, and that you can email me directly using the “Contact” button in the button bar.

©2009 Michael L Nichols. All rights reserved.

What next?

Your comments are always welcome, and are important to this blog’s community! Leave a comment now, or read the comments.

You can find several related articles in the “Related Articles” list below. In the footer you will find a lists of Popular Posts, Recent Posts, and you may browse by Categories, or tags. There’s also a Google Custom Search box to help you find just what you want.

Get free updates by RSS or email!

If you have enjoyed this article, please consider subscribing to article updates, using an RSS reader, or by email. It’s free and is a great way to make sure you don’t miss a single article! I also invite you to follow me on Twitter!

Why not share this article with others!

Share this article with your friends using your favorite social media service, such as StumbleUpon, or Digg. Check out the icons below under “Share This Article With Others” for other social media, including del.icio.us, Technorati, Sphinn, Friendfeed, FaceBook, MySpace andLinkedIn! You can also email or print the article, and even tweet it using Twitter!

Share and Enjoy:
  • StumbleUpon
  • Digg
  • del.icio.us
  • Technorati
  • Facebook
  • MySpace
  • FriendFeed
  • Sphinn
  • LinkedIn
  • Twitter
  • email
  • Print
  • PDF
Related Articles

{ 9 comments… read them below or add one }

Harsh Agrawal July 29, 2009 at 3:53 pm

Hey man thanks this is very useful…

Reply

Mike Nichols August 23, 2009 at 12:39 am

Thank you, Harsh, for the compliment!

I use these boxes all the time — just look at my “call-to-action” boxes at the end of this article. They are not hard to build and use, but I recall as a new Thesis user being puzzled for a long time about how to do it… hence, the article.

Reply

P.K.ARUN September 5, 2009 at 2:51 am

Wow i need this tutorial this is really helpful for adding custom color thanks for sharing.

Reply

Ana October 3, 2009 at 10:45 am

Thanks very much this was very helpful

Reply

steppinout October 4, 2009 at 9:39 pm

Like this one. Thanks for sharing, might use it sometimes

Reply

Mick Dickinson January 7, 2010 at 2:29 am

Mike,
as a total newbie (who’se Thesis site is still in construction) I’ve found your site invaluable. Many, many thanks
Mick

Reply

Matt January 9, 2010 at 11:13 pm

I continue to find help on your site. I do have a question regarding the highlight boxes. I have followed your code and when I preview it looks great. When I publish, I see the highlight box but when I click away and return, the text is there but the box is gone. Any ideas?

Reply

Max February 5, 2010 at 8:08 am

Mike,

Thanks for all the help you provide.
I followed your instructions – copied the code into custom.css and teh into a text widget around my optin form.
The box does not show. I tried FF, IE8 and Chrome.
Any idea what I might do wrong?
the blog is at http://www.myhealthybreakfast.com/blog/

Thanks.

Max

Reply

Brian March 5, 2010 at 8:07 pm

Nicely done. Worked very well for what I was trying to do. How would you change the color of the text within the DIV?

Reply

Leave a Comment

  • Visit My Other Site!