Full site: cleanslatecss.com
Cleanslate is an extreme CSS reset stylesheet. It is used to reset the styling of an HTML element and all its children, back to default CSS values. It is composed exclusively of !important rules, which override all other types of rules.
- Include a
<link>to cleanslate.css in the host page
- Add the class
cleanslateto the HTML container element of the widget
!importantto all of the widget's CSS rules
- (optional) Set the default styles on the widget container
For more details, see 'Usage'.
Why would I need it?
Cleanslate is useful when there are existing CSS styles on a page, and you want to prevent those styles cascading into some part of the page. This is not a stylesheet to use when developing your own website (for that, try Eric Meyer’s classic Reset CSS or the HTML5 Doctors’ adaptation).
The stylesheet can be useful when distributing content (e.g. a widget, or syndicated news) to third-party websites. The CSS rules in the host site may be unknown and unpredictable, or may change in future without notice, or there may be so many websites you need to distribute to that it is impractical to write specific CSS that overrides the styles in each one. In such situations, the Cleanslate stylesheet will aggressively reset your portion of the content (and nothing else) back to some reasonable default values that you can then build from.
Why not just use an iframe?
However, iframes have some drawbacks:
- You cannot display content outside of the box of the iframe
- It is tricky to resize the iframe to match the size of its contents
- Your content will be unable to interact with the host page, even if it is trusted
- Search engines like Google will not see the content on the host page. Content that is syndicated from a partner website can avoid this by being directly included in the host page.
iframe-based resetting for distributed content
How does it do it?
The stylesheet lists all possible HTML elements, and assigns them the default (or otherwise appropriate) values for every CSS property. It only looks within elements that have a
class attribute of “@cleanslate@”.
Pull requests are welcome. Please comment on the reason for the change.