Bootstrap classes are used to make beautiful and styled alert for web pages. And this is most easy way to make an alert.
Example of different alerts
In this example differt alert
class are used.
And each class has it own properties like their different
background colors.
<
div
class
="
alert alert-success
">
<
b
>
Success !<
/b
>
This alert box for success message.<
/div
>
<
div
class
="
alert alert-info
"
>
<
b
>
Info !<
/b
>
This alert box is for info message.<
/div
>
<
div
class
="
alert alert-warning
"
>
<
b
>
Warning !<
/b
>
This alert box for warning message.<
/div
>
<
div
class
="
alert alert-danger
"
>
<
b
>
Danger !<
/b
>
This alert box for danger message.<
/div
>
<
div
class
="
alert alert-primary
"
>
<
b
>
Primary !<
/b
>
This alert box is used for important message.<
/div
>
<
div
class
="
alert alert-secondary
"
>
<
b
>
Secondary !<
/b
>
This alert box is used for less important message.<
/div
>
<
div
class
="
alert alert-dark
"
>
<
b
>
Dark !<
/b
>
This alert is for dark alert.<
/div
>
<
div
class
="
alert alert-light
"
>
<
b
>
Light !<
/b
>
This alert is for light grey alert.<
/div
>
Output of above code
Alert with close property
In this example alert-dismissible
bootstrap class is used to make
an alert dynamic. It will hide the box at click on the close button.
<
div
class
="
alert alert-success alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Success !<
/b
>
This alert box for success message.<
/div
>
<
div
class
="
alert alert-info alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Info !<
/b
>
This alert box is for info message.<
/div
>
<
div
class
="
alert alert-warning alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Warning !<
/b
>
This alert box for warning message.<
/div
>
<
div
class
="
alert alert-danger alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Danger !<
/b
>
This alert box for danger message.<
/div
>
<
div
class
="
alert alert-primary alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Primary !<
/b
>
This alert box is used for important message.<
/div
>
<
div
class
="
alert alert-secondary alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Secondary !<
/b
>
This alert box is used for less important message.<
/div
>
<
div
class
="
alert alert-dark alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Dark !<
/b
>
This alert is for dark alert.<
/div
>
<
div
class
="
alert alert-light alert-dismissible
"
>
<
button
type
="
button
"class
="
close
"
data-dismiss
="
alert
"
>
×<
/button
>
<
b
>
Light !<
/b
>
This alert is for light grey alert.<
/div
>
Output of above code
Alert links example
In this example alert-link
bootstrap class is
used to make a link as an alert.
<
div
class
="
alert alert-success
"
>
<
b
>
Success !<
/b
>
Visit this<
a
href
="
#
"
class
="
alert-link
"
>
success message<
/a
>
<
/div
>
<
div
class
="
alert alert-info
"
>
<
b
>
Info !<
/b
>
Visit this<
a
href
="
#
"
class
="
alert-link
"
>
info message<
/a
>
<
/div
>
<
div
class
="
alert alert-warning
"
>
<
b
>
Warning !<
/b
>
Visit this<
a
href
="
#
"
class
="
alert-link
"
>
warning message<
/a
>
<
/div
>
Comment here
If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.