By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,493 Members | 1,936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,493 IT Pros & Developers. It's quick & easy.

Ignore CSS for a partcular div in the page

P: 3
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
Share this Question
Share on Google+
8 Replies


drhowarddrfine
Expert 5K+
P: 7,435
Add !important to the css property and it will override the user rule.
Apr 5 '07 #2

P: 3
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

P: 70
Instead of using general rules set span class rules.
Apr 5 '07 #4

drhowarddrfine
Expert 5K+
P: 7,435
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 2.5K+
P: 4,059
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

P: 3
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 2.5K+
P: 4,059
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

P: n/a
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.