CSS Overriding and Scope

<div id="foo">
..... more markup .....

Assume all CSS rules for the content inside have an id selector of "foo" as the prefix


#foo p{...}
#foo #myspan{....}

Is there any way for these rules to modify/affect CSS outside of the div? Reason being I plan on pre-fixing in this fashion to all user supplied CSS rules so my main page cannot be modified (I don't want to apply !important on all of my rules). Thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

#foo p {}

Means only apply the style to paragraphs inside an element with the ID foo.

#foo #myspan{}

Means only apply the style to a element with the ID myspan inside an element with the ID foor.

If p or #myspan are anywhere else on the page the styles will not be applied to them, they must be inside foo for the style to be applied.

No any style prefixed with #foo can only affect the styling inside the element with the ID foo.

This will do what you are after.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.