English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
0

I was going through someone's html. I came across this piece of code in the css part where he was trying to create a box:
margin: 0 20px 0 0 !important;
margin: 0 8px 0 0;
I don't get why did he have to declare the margin twice and is that "important" preceded by an exclamation mark a comment?

2007-04-20 05:31:25 · 5 answers · asked by TheInsider 2 in Computers & Internet Programming & Design

5 answers

it's for internet explorer - as it doesn't work properly you have to put 'hacks' in place for css to work properly.

I use a method like this:

margin: 10px 10px 10px 20px
_margin: 10px 10px 10px 30px

this means that all browsers will make a margin of 10 all round and 20 on the left, the next one is only seen by internet explorer (it ignores the underscore) and overrides the previous margin setting so that the page renders correctly.

2007-04-20 07:13:27 · answer #1 · answered by circusmort 5 · 0 0

The !important makes that rule override any other rules that set the same property in other contexts.

I don't know why there are two margin rules, but tweo possibilities might be: 1. It's on myspace, so the person has utterly no clue what they're doing, or 2. it's some kind of hack to make some browsers process the first rule and others process the second rule.

2007-04-20 12:40:46 · answer #2 · answered by undercoloteal 3 · 0 0

!important is not a comment: it is an override. In other words: it forces the margin setting for that element to be interpreted as a bit more "important" than others. One place to see how that works is, CSS: The Definitive Guide by Erik Meyer (which is THE book you need to read for everything CSS...)

2007-04-20 12:39:25 · answer #3 · answered by fjpoblam 7 · 0 0

"margin" is a tag modifier used for such tags an "body" "table" "tr" "td" and so on.
These are always between brackets
If you read backward from "margin", you will find an opening bracket, immediately before the bracket is the tag being modified.

Check out the W3C website for complete details on CSS, HTML, DHTML, XML
http://www.w3.org/Consortium/

2007-04-20 13:00:01 · answer #4 · answered by Anonymous · 0 0

could be some sort of css filter. search google for css filters

2007-04-20 12:42:30 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers