Simple Guide to Highlighting Content Within Your Posts for Those with Limited Technical Skills

by Jason Francis Hunter on April 22, 2008

Highlighting Content

Part nine of: “Stylizing Your Content”.

Sometimes we need to highlight a specific chunk of text. This should get you started:

Open up your Stylesheet — style.css — and add the following:

/* note: Grey */
p.note {
padding: 0.57143em 0.78571em;
background: #f5f5f5;
border: 1px solid #ddd;
}

/* alert: Yellow */
p.alert {
padding: 0.57143em 0.78571em;
background: #ffffa0;
border: 1px solid #e5e597;
}

/* info: Red */
p.info {
padding: 0.57143em 0.78571em;
background: #ff4f52;
border: 1px solid #ef1d21;
}

/* download: Green */
p.download {
padding: 0.57143em 0.78571em;
background: #a3df61;
border: 1px solid #7abf2f;
}

Now, whenever you have a specific block of text (a paragraph) that you want highlighted in a specific way (e.g. a yellow alert), all you have to do is wrap that text in a paragraph tag with the appropriate class attribute, like so:

<p class=”alert”>This paragraph will be contained within a yellow box, signifying an “alert.”</p>

<p class=”note”>This paragraph will be contained within a grey box, signifying a “note.”</p>

<p class=”download”>This paragraph will be contained within a green box, signifying a “download.”</p>

<p class=”info”>This paragraph will be contained within a red box, signifying “info.”</p>

You can call the classes anything you’d like, you can even add more — and put images inside, like this:

If you haven’t done so already, please subscribe to Scribbles and Words. It’s good for your heart. Plus, your feed reader is looking malnourished. Give it a healthy dose of S&W.

All I did there was add an image to the css, like so:

/* subfeed: Feed Image */
p.subfeed {
padding: 0.57143em 0.78571em;
background: #f2f2f2 url ('images/corner-feed.gif') no-repeat top right;
border: 1px solid #ddd;
}

Good luck!

Image credit: sektordua.

Bookmark/Share this post: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • StumbleUpon
  • del.icio.us
  • bodytext
  • Mixx


{ 17 comments… read them below or add one }

1 Matt Tuley 04.22.08 at 8:36 am

The more of these great tips I come across, the more appreciation I have for just how powerful CSS is. Thanks!
Now, how I need to figure how to combine the RSS graphic idea you finish with with the What Would Seth Godin Do? Wordpress plugin.

Now, could you share with us the code you use to affect the “Bookmark/Share this post:” icon row at the end? I like it much better than what the plugin I currently use does.

2 lawton chiles 04.22.08 at 3:25 pm

CSS rocks- thanks Jay for this better-late-than-never installment! :)

Rock on.

Dude, my sidebar needs work. what do you suggest?

lawton chiless last blog post..The Value Of Free Blogging

3 Jay Francis Hunter 04.22.08 at 4:31 pm

@ Matt - Powerful stuff it is.
Here’s how you can manipulate the WWSGD plugin:

Open up the what_would_seth_godin_do.php file and look for the following (it’s near the top):

<p style='border:thin dotted black; padding:3mm;‘>If you’re new here, you may want to subscribe to my <a href=’”.get_option(’home’).”/feed/’>RSS feed</a>

And, replace the red part with something like this:

padding: 0.57143em 0.78571em; background: #f2f2f2 url ('images/corner-feed.gif') no-repeat top right; border: 1px solid #ddd;

As far as the bookmark plugin, I just use that as it is. The plugin is called Sociable.

4 Jay Francis Hunter 04.22.08 at 6:34 pm

@ Lawton - It did take a while, didn’t it? ;)

I say clean it up a bit. Get rid of stuff that doesn’t really need to be there. Like, what is that magnify thing? Move the subscribe section to the top, along with the search bar. Add a popular posts section. Consider dropping the ClickBank ad or moving it to a lower position. What happened to that video intro you had?

5 lawton chiles 04.22.08 at 7:23 pm

I took the video down, not many were watching i don’t think. I’ll do another one. How do I add a popular posts section?

lawton chiless last blog post..“That’s It. I’m Going To Set The Building On Fire.”

6 lawton chiles 04.22.08 at 8:26 pm

Re-designed, as ordered, Sir.

lawton chiless last blog post..“That’s It. I’m Going To Set The Building On Fire.”

7 NaijaEcash 04.23.08 at 7:52 am

Thanks for this cool tip. For the non-technical this is so much time saving. It sure will add color to my site and make my post easier to read. Cheers.

8 lawton chiles 04.23.08 at 9:11 am

Jay sorry, posted that comment in the wrong poster before. what i meant to do was post here- about the rss mini-call to action. i can make my background white and get a while rectangle,right?

And then i just push it into the singlepost.php file?

9 Jay Francis Hunter 04.23.08 at 7:32 pm

@ Lawton - That is correct.

To add a popular posts section, just add a new widget to your sidebar and add in some posts. You can do it manually or use a plugin.

10 Jay Francis Hunter 04.23.08 at 7:32 pm

@ NaijaEcash - Hope it works for you. If you have any questions, shout. :)

11 Filipe 04.27.08 at 6:09 pm

Cool. How do you get this to work in a sidebar widget though?

12 Jay Francis Hunter 04.28.08 at 7:01 am

Have you tried throwing that HTML in a text widget…and adding the necessary CSS to your stylesheet? It should work.

13 lawton chiles 05.02.08 at 11:54 am

Jay, can these styles be anywhere in my css style sheet? i’m not seeing it render when i preview in firefox.

14 Jay Francis Hunter 05.02.08 at 4:42 pm

Make sure you don’t have any cache plugins turned on. Also, you may want to add .entry before the css declaration.

15 Web Quotes and Counterpoints V | Adam Pieniazek 05.06.08 at 8:05 am

[…] of my appreciation for the skills of Jay from Scribbles & Words but for you newbies, check out this great, quick tutorial from Jay about how to highlight text using only […]

16 lawton chiles 05.09.08 at 11:43 am

Jay, waht about adding quotes and pull styles to the css?

lawton chiless last blog post..How To Explode The Number Of Visitors To Your Website-For Cheap!

17 Jay Francis Hunter 05.09.08 at 4:55 pm

You mean blockquotes? You can find that here.

As for pull quotes, you can use Arc90’s cool JavaScript solution (adds images too) or check out Chris’s guide to pullquotes.

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recommended Resources

Advertise on Scribbles & Words