Thought we could start a thread about some useful CSS tips and techniques, so we can learn from each other :lol:
Here’s my contribution. For the longest time, I never knew that you can actually assign two (or more) classes to the same element. This is useful when you have multiple elements that share a lot of properties, but aren’t exactly identical. Put the common properties in one class, then use the second class for the properties that differ. For example:
…or use h1 and h2 (at least in that example).
EDIT: I suppose my point is that using it for titling things is silly when you could just use some css like
but I am not sure if that is normal or if I am being unsemantic or something.
A better use of multiple class selectors would probably be more easily exemplified with conditional body statements, similar to those used in modular web pages that achieve page-specific navigation appearances.
Here’s a cool way to send different values to IE6 and Firefox for the same property:
By default, the second height property would take effect because it comes later in the stylesheet, but Firefox sees !important and gives the first height value precedence. IE6 incorrectly ignores !important and uses the second value.
IE6 does actually recognize !important, but just not in this context. For example, if you had "height: 200px; !important" in an external stylesheet, it would override "height: 150px;" in an internal or inline style.
To circumvent the issue add this straight after the page title in the HTML and not in a separate file:
Now change the .hidden declaration to:
An important accessibility consideration.
For IE6, I use the following hack; is very similar to yours …
That works too. You could also do something like:
IE ignores the underscore and sets the height to 150px; Firefox and other browsers interpret "_height" as an unknown property and ignore it.
All of these methods work, but I like the first one the best (the one I posted above using !important) because it also validates.
You must be logged in to reply to this topic.