Jump to content

CSS "Exclusion"


johno
 Share

Recommended Posts

Hey!Does anybody know of a way to "exclude" a css rule for a single element?For example, say I wanted to hide everything on a page, EXCEPT for ID "doNotHide".

<style>body {display: none;}.doNotHide {/* Do not hide me! *\}</style>

Thanks a lot :) John

Link to comment
Share on other sites

<style>body {display: none;}.doNotHide {display: block;}</style>

maybe this?after all, the fact that doNotHide is a class name and (supposibly) belongs to a child of body, it means it's treated with higher priority, making everything besides it invisible.Just notice that in the above case, your elements from this class should be block elements. Otherwise, they'll get the features of block elements.

Link to comment
Share on other sites

Thanks for the reply!

<html xmlns="http://www.w3.org/1999/xhtml"><head><style>body {display: none;}.doNotHide {display: block;}</style></head><body>I SHOULD VANISH, LIKE MAGIC!<p class="doNotHide">I should still be here :)!<hr></p></body></html>

Nothing seems to appear.

Link to comment
Share on other sites

Try this CSS instead then:

<style type="text/css">body {  visibility: collapse;}.doNotHide {  visibility: visible;}</style>
Link to comment
Share on other sites

W3 CSS Rules:

display: none This value causes an element to generate no boxes in the formatting structure (i.e., the element has no effect on layout). Descendant elements do not generate any boxes either; this behavior cannot be overridden by setting the 'display' property on the descendants.
Link to comment
Share on other sites

Try this, works on IE, FF and Opera. Basically just put everything in a div and hide it, not the body.

<html xmlns="http://www.w3.org/1999/xhtml"><head><style>.hide {visibility:hidden;}.doNotHide {visibility:visible;}</style></head><body><div class="hide">I SHOULD VANISH, LIKE MAGIC!<p class="doNotHide">I should still be here :)!</p><hr class="doNotHide" /></div></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...