Message Boxes with CSS

— Following the line of the previous post, here is another set of reusable classes I like to use. This time to create Message Boxes which I found myself using in almost every site I make, mostly on the forms. These Message Boxes are useful to display and inform in a nice way different messages, like announcements, alerts, or status information. I like to keep things simple so i use a very clean style:

→ Styles Demo: view the demo | ↓ Download

CSS classes:

Nothing too fancy or complicated. I use a main class .message-box , and then the different style variations separated, but just to dont repeat code and keep things more organized:

/* MESSAGE BOXES
/////////////////////////////*/

.message-box { text-align: center; padding: 5px; color:#545454; width:80%;  margin:5px auto; }

.clean { background-color: #efefef; border-top: 2px solid #dedede; border-bottom: 2px solid #dedede; }
.info  { background-color: #f7fafd; border-top: 2px solid #b5d3ff; border-bottom: 2px solid #b5d3ff; }
.ok    { background-color: #d7f7c4; border-top: 2px solid #82cb2f; border-bottom: 2px solid #82cb2f; }
.alert { background-color: #fef5be; border-top: 2px solid #fdd425; border-bottom: 2px solid #fdd425; }
.error { background-color: #ffcdd1; border-top: 2px solid #e10c0c; border-bottom: 2px solid #e10c0c; }

How to use them:

It is very easy to implement them, you have to first add the message-box class and then the wanted style class ( .clean, .info, .ok, .alert or .error ) to the element you want to use as message box. I tend to use a <p> element to display them:

<p class="message-box info">This is an Info Message</p>

<p class="message-box ok">This is an Ok Message</p>

<p class="message-box alert">This is an Alert Message</p>

<p class="message-box error">This is an Error Message</p>
→ Styles Demo: view the demo | ↓ Download

And thats it. Simple but nice looking! I hope you enjoyed.

Tags: , , ,

  • del.icio.us
  • DZone
  • Design Float
  • Technorati
  • Reddit
  • StumbleUpon
  • E-mail this story to a friend!
Friday, July 25th, 2008 Web Design

→ If you find this post useful please consider inviting me a cup of tea :) Thanks!

10 Responses to “Message Boxes with CSS”

  1. Great Post! Concise and to the point. If only ALL tech bloggers were like you lol. The Web would be sweeet!

  2. Niche P on July 27, 2008.
  3. It’s very elementary but practical tut. I like it! Thanks

  4. Mohsen on July 28, 2008.
  5. I appreciate your comments, Thank you!

  6. Matt on July 29, 2008.
  7. Good color choices

  8. Dan on September 9, 2008.
  9. I like it! Thanks!

  10. Alice on September 9, 2008.
  11. Hey! This is so good!

  12. Marcus Sá on November 19, 2008.
  13. Awesome post. It was like a CSS a-ha moment. I spruced up 3 blogs with your code. It makes posts more readable, to break it up with short punchy message boxes in this technique. Thanks.

  14. Dgold on November 27, 2008.
  15. @Dgold Glad to hear that, you are welcome. Thank you for the nice comment :)

  16. Matt on November 27, 2008.

Leave a Reply

About Me

Matt Varone - Matias Varone - sksmatt
HI there,

I'm a freelance creative web developer, UI designer and WordPress lover.

Twitter Status

Flickr Gallery

    Clutter drawerCS4 Replacement iconsCS4 Replacement iconsMagic

Scrnshots Gallery

  • Screenshot from ScrnShots.com
  • Screenshot from ScrnShots.com
  • new site im working on
  • Screenshot from ScrnShots.com