Adding css into a js alert message

2875 views javascript

Im trying to add some css into java script alert message where alert message will get values to alert from php $_POST[];. Please see the below code

$brandname = $_POST["brandname"];

    alert ('Your brand $brandname successfully added into system & redirecting to brand list page');

what i wants to do is add h1 tag and change the color of $brandname value. So could any explain me how to do that.

answered question

You have no control over alert styling, instead set a variable on the redirect, and on the page it hit then show the styled message. what your doing is 1986 style coding.

You cannot do it with an alert box. But using jQuery UI Dialog you can do the styling

1 Answer


The alert box is a system object, and not subject to CSS. To do this style of thing you would need to create an HTML element and mimic the alert() functionality. The jQuery UI Modal box does a lot of the work for you, working basically as I have described:

posted this

Have an answer?


Please login first before posting an answer.