467,910 Members | 1,781 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,910 developers. It's quick & easy.

Ignore CSS for a partcular div in the page

Hi,

I am working on a Widget that gets embedded into an existing page as a div in the body...Now I want to ensure that the my widget looks and behaves exactly the same on all web sites.

But I am running into issues where customers have setup global CSS rules for all sorts of elements like

table {border:1px solid}
a {text-decoration:underline}
etc.

Now is there a clean way for me to ignore all these rules without writing rules for each and very possible property?

Thanks,
Jitendra
Apr 5 '07 #1
  • viewed: 12706
Share:
8 Replies
drhowarddrfine
Expert 4TB
Add !important to the css property and it will override the user rule.
Apr 5 '07 #2
I don't think that will work...I'll have to set properties for each conceivable element and all properties for each element...that could be a tall task...
Apr 5 '07 #3
Instead of using general rules set span class rules.
Apr 5 '07 #4
drhowarddrfine
Expert 4TB
Then there is no other way to override user CSS rules.

Now that I re-read the original post, I should say that I was thinking you meant user CSS on the individual browser. If you meant they import some global CSS file, then as long as your CSS follows theirs, then the cascade will take care of what you want. You can modify what they have but you can't delete what they have.
Apr 5 '07 #5
KevinADC
Expert 2GB
Yea, thats pretty much why they are called Cascading Style Sheets. Plus I doubt other people would like the fact you control the appearance of content that gets displayed on their site (If I understand your situation). Besides, they could just slurp your html code up and alter it anyway they want to if they know some server side stuff. All in all it sounds like a concept that is not practical.
Apr 5 '07 #6
An example of the scenario I am thinking of available at Techcrunch

Steps:

1. Go to techcrunch.com
2. Click on the "sphere it" link at the end of each post
3. this causes a new div to get generated

This div popup works the same across mutiple sites... (check out www.readwriteweb.com for another example). Now these popups are custom to the site...But my question is that is there a way to generate this kind of popup without having to worry about the site specific CSS and without having to define the all CSS properties for all elements.

Thanks every one for the responses thus far.
Apr 5 '07 #7
KevinADC
Expert 2GB
The answer is: no. And you should not even be trying to do that. It's a bad idea, its not practical, and it can still be defeated even if you define ever CSS property known to man within the div itself.
Apr 5 '07 #8
It's very practical. The need to do this, normally with included HTML just like the scenario suggested, comes up all the time. There should be a CSS property that specifies css file names to read or ignore when computing the cascade. Of course it can be "defeated." That's not the point. We aren't talking about potential malicious behavior here. We are talking about convenience. The ability to ignore certain css files would be VERY convenient.
Nov 12 '10 #9

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by Nicolas Fleury | last post: by
1 post views Thread by windandwaves | last post: by
4 posts views Thread by Jon Westmore | last post: by
1 post views Thread by Ganesh | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.