Search code examples
csshtmlwidth

DIV width not listening to my CSS


The code below is an example of what I am trying to do, I need this div to span 600px wide however regardless if I put max-width: 600px; or width: 600px; it is still the width of my PC screen.

How can I make it 600px wide?

<style>
.errormsg3 { 
    text-align: center;
    font-weight:bold;
    color:white;
    font-size: 16px;
    background-color:red;
    padding:8px;
    max-width: 600px;
}
</style>

<?PHP
if (isset($_SESSION['sess_msg'])) {
    echo '<div class="errormsg3">' .$_SESSION['sess_msg']. '</div>';
    unset($_SESSION['sess_msg']);
} 
?>

UPDATE

It is working now, firefox seems to be caching my site so maybe thats why it wouldn't work before.

The div is red, is it possible to add padding to the div, outside of the red part, so there is like a padding/space that is white


Solution

  • That CSS works fine for me. Are you sure you don't have another CSS rule that's overriding it? Try using a tool like Firebug that can show you the computed style for an element and where it came from.