Some examples of notification messages for your website

Written by Richard Heyes, on 30th October 2023

Introduction

Here's some success, warning and error message styles that you could use on your website or in your web application. Use them to give your users information or messages (for example on successful or failed submission of a form) and to clearly indicate the severity of the information.

The CSS for the message styles

Here's the css that's necessary for the message styles.

<style>
    /*
    * Styles that apply to all three styles of message
    */
    div.rgraph-error-message-container,
    div.rgraph-warning-message-container,
    div.rgraph-success-message-container,
    div.rgraph-notice-message-container {
        font-family: Arial;
        position: relative;
        border-radius: 10px;
        width: calc(100% - 10px);
        margin-top: 15px;
        margin-bottom: 15px;
        line-height: 20px;
    }
    
    div.rgraph-error-message-container   > div,
    div.rgraph-warning-message-container > div,
    div.rgraph-success-message-container > div,
    div.rgraph-notice-message-container > div {
        background-color: white;
        border-radius: 10px;
        position: relative;
        left: 7px;
    }

    div.rgraph-error-message-container   > div > div,
    div.rgraph-warning-message-container > div > div,
    div.rgraph-success-message-container > div > div,
    div.rgraph-notice-message-container > div > div {
        border-radius: 10px;
        padding: 15px;
        position: relative;
    }

    div.rgraph-error-message-container   > div > div > span,
    div.rgraph-warning-message-container > div > div > span,
    div.rgraph-success-message-container > div > div > span,
    div.rgraph-notice-message-container > div > div > span {
        font-weight: bold;
    }




    /*
    * Set the colors for each message style
    */
    div.rgraph-success-message-container                    {background-color: #0a0;}
    div.rgraph-success-message-container > div              {border: 1px solid #0a0;}
    div.rgraph-success-message-container > div > div        {background-color: #0f04;}
    div.rgraph-success-message-container > div > div > span {color: green;}

    div.rgraph-warning-message-container                    {background-color: #e7c000;}
    div.rgraph-warning-message-container > div              {border: 1px solid #cc0;}
    div.rgraph-warning-message-container > div > div        {background-color: #fff7d0;}
    div.rgraph-warning-message-container > div > div > span {color: #aa0;}
    
    div.rgraph-error-message-container                     {background-color: red;}
    div.rgraph-error-message-container > div               {border: 1px solid #c00;}
    div.rgraph-error-message-container > div > div         {background-color: #f004;}
    div.rgraph-error-message-container > div > div > span  {color: red;}
    
    div.rgraph-notice-message-container                     {background-color: blue;}
    div.rgraph-notice-message-container > div               {border: 1px solid #00c;}
    div.rgraph-notice-message-container > div > div         {background-color: #00f4;}
    div.rgraph-notice-message-container > div > div > span  {color: blue;}
</style>

Success message

Success
This is a success message.
<div class="rgraph-success-message-container">
    <div>
        <div>
            <span>Success</span><br />
            This is a success message.
        </div>
    </div>
</div>

Warning message

Warning
This is a warning message that you may see when you've done something that is not an error - but still quite serious.
<div class="rgraph-warning-message-container">
    <div>
        <div>
            <span>Error</span><br />
            This is a warning message that you may see when you've
            done something that is not an error - but still quite
            serious.
        </div>
    </div>
</div>

Error message

Error
This is an error message that you may see when you've done something that is not allowed!
<div class="rgraph-error-message-container">
    <div>
        <div>
            <span>Error</span><br />
            This is an error message that you may see when you've
            done something that is not allowed!
        </div>
    </div>
</div>

Notice message

Notice
This is a notice message that you may see when a bit of text is informational.
<div class="rgraph-notice-message-container">
    <div>
        <div>
            <span>Notice</span><br />
            This is a notice message that you may see when a bit of text is informational.
        </div>
    </div>
</div>