The HTML
As shown in the image above, we will use a DIV with a class "message" and add another class value to it (following a space) depending on the message. Notice the class attributes below.
- <div class="message notice">this is a notice.</div>
- <div class="message success">something was successful.</div>
- <div class="message error">oops! an error occured.</div>
The CSS
Since "message" will be used as the default class for the container, we need to define its padding, background colour, colour (text) and border properties.
- .message {
- padding: 10px;
- border: 2px solid #ddd;
- background-color: #eee;
- color: #222;
- }
Now three more classes - notice, success, and error. They are all same in terms of properties, but notice their colour values. Background colour is a bit lighter than the solid border.
- .notice {
- background: #FFF6BF;
- color: #817134;
- border-color: #FFD324;
- }
- .success {
- background: #E6EFC2;
- color: #529214;
- border-color: #C6D880;
- }
- .error {
- background: #FBE3E4;
- color: #D12F19;
- border-color: #FBC2C4;
- }
Simple enough for anyone to understand. You can add more classes depening on how many message boxes you need for your site. Just make sure your container looks like <div class="message myclass"> ... </div>, and it should be fine. Now try adding a few more classes and play with the colour combination. Its fun!













