I'm Calin Baenen – AKA KattyTheEnby – a programmer born October 30th, 2006.
I love programming, it has been my passion since I was a kid, and will forever be my passion.
I KNOW they have it by default, but I'm using body *, but I want to negate this styling from the specific elements that begin with (or (only) POSSIBLY have) styling none, so that I don't have to specify all of the ones that are hidden, or update my CSS in the future (if more default-hidden elements are put into HTML).
I have also never thought about applying styling to tags like script. Is the problem you are having that styles are being applied to <script> elements in the body of your page?
It's a strange problem you've run into. It's because body * is a very generous selector. Too generous for changing the display property. As you've highlighted, this makes script elements visible. As a best practice you'll want to be more specific with what elements you apply style rules to.
An alternative here would be to create an extra "container" element for all your visible elements. For example:
<body><divclass="container"><h1>Title</h1><!-- all your "visible" elements here --></div><script>/* Script tags and any other "hidden" elements outside the container */</script></body>
Then you can be more specific with your style rules, without affecting the script elements:
body.container*{display:inline-block;/* your other style rules */}
link elements are more commonly placed in the <head> of a web document, so you shouldn't need to worry about styles being applied to them if you move them to the <head>.
I hope that helps solve your problem. But if you do want to exclude elements like link and script, you should be able to do so with:
I KNOW they have it by default, but I'm using
body *, but I want to negate this styling from the specific elements that begin with (or (only) POSSIBLY have) stylingnone, so that I don't have to specify all of the ones that are hidden, or update my CSS in the future (if more default-hiddenelements are put into HTML).I have also never thought about applying styling to tags like
script. Is the problem you are having that styles are being applied to<script>elements in thebodyof your page?It's a strange problem you've run into. It's because
body *is a very generous selector. Too generous for changing thedisplayproperty. As you've highlighted, this makesscriptelements visible. As a best practice you'll want to be more specific with what elements you apply style rules to.An alternative here would be to create an extra "container" element for all your visible elements. For example:
Then you can be more specific with your style rules, without affecting the
scriptelements:linkelements are more commonly placed in the<head>of a web document, so you shouldn't need to worry about styles being applied to them if you move them to the<head>.I hope that helps solve your problem. But if you do want to exclude elements like
linkandscript, you should be able to do so with: