 |
05-21-2008, 07:26 PM
|
!important;
|
Posts: 9
Name: BlakeTallos
Location: Cuyahoga falls,Ohio
|
Quote:
<style>
html body.bodyContent table tbody tr td table.friendsComments{
width: 770px !important;
margin: 0 !important;
padding: 0 !important;
margin-top: 20px !important;
overflow: hidden !important;
background-color: transparent !important;
margin-left: -1px !important;
_width: 770px !important;
_margin-left: -2px !important;
}
|
when you see something like !important;
is that just basically making a comment ??
will that work like a comment
html comment code is <!--html-->
and css comment code is
/* This is a comment */
But can we use !important; instead??
|
|
|
|
05-21-2008, 09:44 PM
|
Re: !important;
|
Posts: 6,746
Location: Tennessee
|
Quote:
when you see something like !important;
is that just basically making a comment ??
|
No, it's not a comment, it's a HACK and for the most part there is no reason to use it if your code is written correctly.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
|
|
|
|
05-21-2008, 10:41 PM
|
Re: !important;
|
Posts: 9
Name: BlakeTallos
Location: Cuyahoga falls,Ohio
|
Oh i see well now i know!! There was a Website that i saw and all i saw were !important; "Hacks"
I was like woah that's not normal so i had to bring it Up!!
people usually do those to Make there Code to Align Properly with the browser there using right ?
|
|
|
|
05-22-2008, 05:51 AM
|
Re: !important;
|
Posts: 691
Location: Kokkola, Finland
|
Quote:
Originally Posted by LadynRed
No, it's not a comment, it's a HACK and for the most part there is no reason to use it if your code is written correctly.
|
are you SURE itīs a hack? how does it fit your definition of a hack? iīve seen eric meyer use it in one of his books, and it can be useful when used with caution in regard to a userīs possible own stylesheet setup.
|
|
|
|
05-22-2008, 09:21 AM
|
Re: !important;
|
Posts: 377
Name: Venkat Raj
Location: Salem, South India
|
Its NOT a Hack, not even a Filter. Its a valid DECLARATION. Of course, you can use it as hack/filter. http://www.w3.org/TR/REC-CSS2/cascad...mportant-rules
__________________
All the Buddhas of all the ages have been telling you a very simple fact: Be -- don't try to become.
|
|
|
|
05-22-2008, 10:44 AM
|
Re: !important;
|
Posts: 6,746
Location: Tennessee
|
It is most often USED as a hack and, yes, it has it's place, but I have never found the need to use it - not once. I have a colleague, however, who does use it, and he uses it most often because he doesn't get his specificity correct. I've been able to remove it in every single instance where he used it, replacing it with more specific coding.
Quote:
|
people usually do those to Make there Code to Align Properly with the browser there using right ?
|
Nope, they use it for all kinds of things.
Oh.. and this is one of my pet peeves.. 
there = a place
their = is a possessive pronoun. It always describes a noun ie. "it's THEIR apartment".
they're - contraction for "they are"
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!
"Using or working with IE is like having to wear a 1970's polyester suit with pantyhose and a girdle, to work everyday"
Carolina Corvette Club
|
|
|
|
05-22-2008, 03:37 PM
|
Re: !important;
|
Posts: 1,382
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
Whenever I add an !important tag to my code, I feel the gloom and doom of the finality it suggests. Handle with care, as it overrides many good and natural things in a stylesheet, such as the specificity. The !important tag can also be used to override inline styles, which is sometimes useful, but also tricky. If you have complete control over your HTML, I believe it is a good thing to never have inline styles. Sometimes this is not the case, and it is then useful to be able to override these styles with !important.
As stated previously in this thread, !important is usually used as a hack, as IE6 has a serious misunderstanding of it. For example:
Code:
#element {
margin: 100px !important;
margin: 0;
}
All the standard browsers will understand that #element has a margin of 100px, because although it appears first in the order, it has the !important tag on it. However, IE6 thinks that because the margin: 0 comes second, it is dominant. This is a way of sending a special message to IE6 in a single CSS document that will pass validation if you need it to. Of course there are many ways to do this...
__________________
<!--if a signature drops in the forest, and no one is there to see it, does it make a link?-->
|
|
|
|
05-22-2008, 07:28 PM
|
Re: !important;
|
Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
|
This is quite interesting, never heard of this before, though even if there was a time when I needed to use it I couldn't do it, ! is set in my mind as not. Do they realize this? I only see this as useful when I'm making a user style-sheet and want to win the war.
__________________
PHP Code:
<?php echo "Hello World"; ?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
|
|
|
|
05-22-2008, 09:47 PM
|
Re: !important;
|
Posts: 1,382
Name: Abel Mohler
Location: Asheville, North Carolina USA
|
I have been working late, and just used the !important remark twice in a row. I remembered this thread, and it just occurred to me a correct usage for this item.
I have a class, which I call 'inviz'. All it does is make an item invisible. It functions like this:
Code:
.inviz {
position: absolute !important;
left: -9999px !important;
}
The reason I specify it this way is the way this class is used: dynamically. In other words, I am using Javascript to place this class (or remove it) from various elements on the page, thereby hiding them or revealing them in real time.
The easiest and best way to create this class is with the !important tag, because it overrides the specificity. Often, you must be careful about overriding specificity, because it is an important element in CSS structure, but in this case, it is exactly what I want. If I place this class on an element, I want it to be the most powerful class on the div, p, or whatever I want to make invisible. I don't want position of relative, for example to take precedence over my absolute, just because it is more specific. Also, I don't want to make a specific rule for each case where 'inviz' might be needed, because that would be too much work. Time is money.
__________________
<!--if a signature drops in the forest, and no one is there to see it, does it make a link?-->
|
|
|
|
|
« Reply to !important;
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|