Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does this "Important" mean?

Status
Not open for further replies.

okpeery

Instructor
Dec 29, 2005
102
US
I am trying to modify this code and play around with it. I want to make the main div container wider.

div#container{width:450px !important; width /**/:460px;
margin: 0

This looks like a fix for something but I don't know what for. Do I need to proportinally increase the 2nd width or does it always need to be 10 px larger? Any ideas?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]
<html>
<head>
<title>Nifty Corners: Javascript and CSS rounded corners</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="generator" content="HAPedit 3.1">
<style type="text/css">
body{padding: 20px;background: #707883;color: #222;text-align: center;
    font: 85% "Trebuchet MS",Arial,sans-serif}
h1,h2,p{margin: 0;padding: 0 10px;font-weight:normal}
p{padding: 0 10px 15px}
h1{font-size: 250%;color: #FFF;letter-spacing: 1px}
h2{font-size: 200%;line-height:1;color:#002455 }
[COLOR=red]div#container{width:450px !important; width /**/:460px;[/color red]
    margin: 0 auto;padding:5px;text-align:left;background:#FFF}
div#header{background: #BFDDED;padding: 10px;text-align:center}
div#content{float:left;width:300px;padding:10px 0;margin:5px 0;background: #778CCA}
div#nav{float:right;width:145px;padding:10px 0;margin:5px 0;background: #FFD154}
div#nav h2{font-size: 120%;color: #9E4A24}
div#footer{clear:both;width:450px;background: #C4E786;padding:5px 0;text-align:center}
</style>
<script type="text/javascript" src="niftycube.js"></script>
<script type="text/javascript">
window.onload=function(){
Nifty("div#container");
Nifty("div#content,div#nav","same-height small");
Nifty("div#header,div#footer","small");
}
</script>
</head>
<body>
<div id="container">
<div id="header"><h1>Nifty Corners</h1></div>
<div id="content">
<p>Auiiui  uieiouo auuaa oiaue uaou iioiiou uiio a io ieeoai uaouoe uoiaau eeauauou u oiauuie eo ui.</p>
<h2>Rounded corners without images</h2>
<p>Aaeao aiieuouiu io ueuiieu uei oeio uooiau uue ooiea ooiaui eue ouue i uiaoo iouieiuia uueeo ieieuiiau
ueaooa iou iaeieuo uoao iauoi u i oeioooe auo a ooe u uuuo oaooaae uoa iuiuiaeu iioaeu uuiu eeu ea eouoiuo ua o.</p>
<p>Iiuiuaea ouea ieuuio o eoo iaoa euiaou uoia
uuei ua aoauia ieoae eioiaia eu uiueeiui ueuaiuo uaa eie oaeee uau ooieoi uoii oeuioei uouiiuu ioeiuoe eaeuoi.</p>
</div>
<div id="nav">
<h2>Simple. Just Javascript and CSS.</h2>
<p>Aoioeou eeeu ueeiuiii uoauiioi uae eoeoioe ouiui oieouoo uioo uaieeoe oe eouoiea a oou uiu.</p>
</div>
<div id="footer">footer here</div>
</div>
</body>
</html>
 
!important lets the users's browser override the authors settings for an element I think

 
It increases the specificity for a CSS property, allowing it to override other rules which previously would have had a higher specificity, and so not been overwritten.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Okay, so what does this important specifically mean in this case? Does it try to account for the different way windows machines and macs calculate pixels per inch or something like that? On a windows machine I increased the size of the main container and complementarily increased the 2 columns and added 10px after important. It looked fine. When I did the same thing on a mac there was a little extra on my footer. I wonder if there was overflow and that is where it was put.
 
It's probably some kind of IE-busting hack. IE (I think) doesn't recognise the, ahem, importance of [tt]!important[/tt] rules - it will just apply whichever one comes later in the stylesheet. So the effect of this sheet is to give [tt]width: 460px[/tt] to IE and [tt]width: 450px[/tt] to modern browsers. I guess that empty comment [tt]/**/[/tt] confuses some version of IE too (IE Mac?).

The bottom line is, you should be OK to change these widths, provided you add the same amount to each width rule.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top