[image: socialicon]

When creating a clean and attractive website, you don’t ever want to ruin it with error pages. Although they are not always unavoidable, many scripts can easily return a clean error message. Using a simple bit of CSS makes your errors display in an smooth, non-aggressive way. This method is also very effective in returning little messages to your user such as “you are now logged in” or “you received a message”.

How

By using the “border” css property it is easy to add a dark border to the top and bottom of each container. Using a color picker choose a light and dark version of a pastel color of your choice. Using icons from FamFamFam and adding a little padding, “Bamm!”, You’re done!

Demo

[image: alertdemo]

The Code

The images needed can be found in the download below.

<html>

<head>
<style>
body {
	color: ##444444;
	font-family: 'Lucida Grande',Verdana,Arial,Sans-Serif;
	font-size: 10px;
	}

.alert {
	background: #fff6bf url(exclamation.png) center no-repeat;
	background-position: 15px 50%;
	text-align: left;
	padding: 5px 20px 5px 45px;
	border-top: 2px solid #ffd324;
	border-bottom: 2px solid #ffd324;
	}

.info {
	background: #F8FAFC url(information.png) center no-repeat;
	background-position: 15px 50%;
	text-align: left;
	padding: 5px 20px 5px 45px;
	border-top: 2px solid #B5D4FE;
	border-bottom: 2px solid #B5D4FE;
	}

.error {
	background: #FFBFBF url(error.png) center no-repeat;
	background-position: 15px 50%;
	text-align: left;
	padding: 5px 20px 5px 45px;
	border-top: 2px solid #FF2424;
	border-bottom: 2px solid #FF2424;
	}
</style>
</head>

<body>
<div class="info">Information you need to know</div>
<br /><br />
<div class="alert">Alert you triggered</div>
<br /><br />
<div class="error">Error with our code</div>
</body>

</html>

Download

See how simple that was? Download the source and images here.

8 Responses to “Professional CSS Alert Boxes”

  1. turboRamble says:

    Nice Charlie! I’ll try to use this on my site….

    Thanks again!
    -turboRamble

  2. Charlie says:

    No Problem! I hope you enjoy using it. :)

  3. turboRamble says:

    Err, I’m on Firefox now (downloaded it for all comps) and the cool background suddenly stops if you scroll down far enough and it turns white….

    Also, I finally set up an affiliates program on my website, and you’re now on it.

    -turboRamble

  4. Charlie says:

    Cool thx!

    Where on the site are you seeing that bug? I’m in firefox and I don’t see anything strange…

  5. Nathaniel Aini says:

    Just wasting some free time on Digg and I found your entry. Not normally what I like to learn about, but it was definitely worth my time. Thanks.

  6. Larue40542 says:

    That is unbelievable and very nicely written. Generally I do not make a comment on the web, However I have to congratulate you on this one. Superb site

  7. hondarider79 says:

    You’re right on the money with this article, keep up the good work!

  8. Pickle says:

    That was intriguing . I admire your finesse that you put into your post . Please do continue with more similar to this.

Leave a Reply

Want an image next to your name? Sign up at Gravatar.com and in a few seconds you will be on your way. If you are signed up on Gravatar, enter the email associated with your Gravatar account when commenting.
Adobe Flash Player is required to view this video.
BrandiniMP Blog: Programming, Gaming

Frills and Furbelows Lillian’s Blog: Food & Fashion

Iain Nash Web Profile

turboRamble Blog: Game Creation, Art, Writings

RJ's Burrow The bright light at the end of the tunnel.

WebDelve Web Development

Property of ThatGuyCharlie, Charlie Mathews | Design by PixelVeritas | Powered by Wordpress