Is there a painless way to make a "css sandbox"?

By CSS sandbox I mean a section in my layout that have a completely independent look. I need this because some classes of mine need to output some "windows" of content in the layout, but I don't want the app's css to mess with them. They're mostly debug related, like printing var contents, benchmark graphs or displaying some error/exception.

Until now I was doing some kind of local reset, but this gets really annoying to avoid collisions and could fail if I forget some rules. ex:

html body {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    font-size: 100% !important;
    vertical-align: baseline !important;
    background-color: #fff !important;
    font: 12px/12px 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    margin-bottom: 20px !important;

html body * {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    font-size: 100% !important;
    font: inherit !important;
    vertical-align: baseline !important;
    color: #333 !important;

html body .title {
    font-size: 50px !important;
    line-height: 75px !important;
    /*font-weight: bold !important;*/

html body .desc {
    font-size: 24px !important;
    line-height: 36px !important;

I don't know much about it, but I think thats more or less what Shadow DOM does

Suicide is not painless, Eleven years ago, my younger brother attempted to commit suicide. He drank over a � gallon of anti-freeze in an effort to end his own life. His� This is particularly common when there is a problem, such as not achieving a goal or being cheated in love or when one is tortured by some disease. The question then becomes whether there is actually any way to die that are truly painless. The reality is that you won’t find any painless way to die.

You can make a container element with an ID and then reset its rules (make sure this part is loaded last). The only problem you might encounter then are the !important rules, but you can use those in your reset part as well (not really recommended practice, but it will work).

Also, depending on the structure of your site, you might want to call your container element as specific as possible, like body #top_element #another_top_element #container in order to give it higher priority, but in most cases this won't be necessary...

What's the best method for a painless suicide?, I am done with life, but don't want to suffer when I go. Make sure you get to a “safe” place, where there is no one around. And make sure when you jump, there are no obstacles on your way. There have been many instances where people jumped off the bridge and got stuck on to a prong on the bridge and remained there hanging awkwardly for hours without food or water, possibly even breaking one of

Another possible solution - depending on your application, is to load that layout section in an iframe - this way its a completely seperate document subject to a seperate set of styles. Not sure if I need to mention that there are certain drawbacks to using frames.

Painless suicide, We are here to offer emotional support through befriending and a stay at our respite centre - a chance for individuals who are feeling suicidal to be heard and � The central question is, therefore, are there painless ways to die? The truth of the matter is you will not find any method that is painless unless it comes without you realizing. However, some methods are faster and less painful. Some methods such as jumping from the top of the roof can make you reconsider the idea of committing suicide.

There has been a technique called Scoped CSS

You can't use it [1] anymore but there is a polyfill [2] you can try.



I helped eight people end their lives. By the time you read this, I'll , Apparently they regarded suicide as a sign of shameful weakness. Al Purdy letter LIFE AND DEATH A 1999 letter from the poet Al Purdy to the� There are many ways to die some are painful and some are painless. Below given is the list by which one can die in least painful way. Thus on advancing we have also advanced in developing the very fast and easiest way to die here are the following ways.

Scientifically, What's the Best Way to Die (Without Killing Yourself)?, Is there any way to go that's relatively painless and trauma-free? There are other sound reasons to continue to live. Medical and psychological researchers continue to find ways to treat mental illness. At 36 you may have 40 years of life or more in which a cure

What is the cheapest, painless, easiest way to commit suicide?, You mentioned taking pills. It's darn near impossible to succeed with pills. I've failed twice. If you take that many pills that fast, you're bound to throw them up. Ways of making injections as painless as possible may seem to be a strange thing for a needle exchange worker to be trying to find. After all if an injection is painful then the person is less likely to inject, right…. no, just think of the number of injectors that come into needle exchanges who a

7. Lethal Means, Lethal means are items or actions that might be used in a suicide attempt that are likely to result in death. Lethal means can be divided into two main categories:� If you are here, reading this, the chances are you are so tired of hurting, so exhausted by the relentless black hole of pain inside you that you are looking for a way, ANY way, to make it stop. Painless suicide methods seem like the holy grail right now. I get it – believe me – I understand. Are There Any Painless Suicide Methods?

  • Create it's own div?
  • If the app styles any tag (think twitter bootstrap for instance), a simple div won't protect my contents from being styled as well.
  • @hugo_leonardo: Why don't you make an iframe? You could also use a local CSS reset, but that won't stop !important properties from leaking through.
  • @Blender now that's a good idea (:
  • maybe if I put !importants in the reset inside... will definetely try that (:
  • wow! That's very neat! If only it wasn't so new and experimental/unsuported. I probably won't be able to use it yet, but anyway, this is awesome. thanks (:
  • !important won’t help against CSS rules that also use !important and have higher specificity. But additionally using an id attribute for the container and using the corresponding id selector as part of all selectors makes the sandbox practically safe.
  • @JukkaK.Korpela Yup, that's what I tried to say in my second paragraph.
  • that's kinda what i'm doing...perhaps if I use the * selector i could ease the proccess? a specific rule with class instead of id would be safe too? because some structures are displayed more than once
  • Yes, using #container_name * selector will shorten the process a lot. ID has a higher priority than a class, that's why I'd go with an ID.
  • i'll keep the question running as this is still kinda paifull, but this was very helpful (: ~ updated my example in the question to reflect these ideas. maybe someone come up with some neat hack :p
  • The drawbacks wouldn't be an issue since it's just for debugging. But this was discussed in the comments and it seems that only chrome and safari supports inline markup in iframe (with the srcdoc property). So it wouldn't help much...