W3.CSS Alerts







googletag.cmd.push(function() { googletag.display('div-gpt-ad-1422003450156-2'); });



W3.CSS Alerts




❮ Previous
Next ❯





×

Danger!


Red often indicates a dangerous or negative situation.





×

Warning!


Yellow often indicates a warning that might need attention.





×

Success!


Green often indicates something successful or positive.





×

Info!


Blue often indicates a neutral informative change or action.






Displaying Alerts


The w3-panel class is the perfect class to display alerts.


Alerts are often displayed using a strong color:




Example



<div class="w3-panel w3-red">
  <h3>Danger!</h3>
  <p>Red often indicates a dangerous or negative situation.</p>
</div> 

Try It Yourself »


The w3-container class
can also be used to display alerts:




Example



<div class="w3-container w3-red">
  <h3>Danger!</h3>
  <p>Red often indicates a dangerous or negative situation.</p>
</div> 

Try It Yourself »








googletag.cmd.push(function() { googletag.display('div-gpt-ad-1493883843099-0'); });






Alerts in Other Colors


Alerts are often displayed in a strong color, but any color can be used:





Danger!


Here w3-pale-red is used.




w3-pink






Warning!


Here w3-pale-yellow is used.




w3-orange






Success!


Here w3-pale-green is used.




w3-blue-grey







Closing Alerts


To close the alert box, click on the X in the upper right corner:



×

Danger!


Red often indicates a dangerous or negative situation.



To create the X that closes the alert, add a <span> element with class
w3-button and an onclick event:



Example



<span onclick="this.parentElement.style.display='none'"
class="w3-button
w3-display-topright">&times;</span>

Try It Yourself »


Tip: The HTML &times; entity is the preferred icon for close buttons
(rather than the letter "X").





Rounded Alerts


Use the w3-round classes if you want rounded corners:



Success!


Here w3-round is used.




Success!


Here w3-round-large is used.




Success!


Here w3-round-xxlarge is used.





Example



<div class="w3-panel w3-green w3-round">

Try It Yourself »



Alert as a Card


Use a w3-card class if you want the alert to be displayed as a card:



Warning!


Yellow often indicates something that needs attention.





Example



<div class="w3-panel w3-yellow w3-card-4">

Try It Yourself »




❮ Previous
Next ❯

Popular posts from this blog

Colors HSL

Google Hardware Icons

SVG Filters