On Jan 18, 6:45 pm, johny why <johny...@gmail.com> wrote:

> "Third party "CSS Candy" that is supposed to be inserted in other's
> pages should be coded with this issue in mind, protecting all it's
> styles in it's own container"
>
>      --i believe that's incorrect, if by "container" you mean unique
> classes and id's. as i describe above, unique id's will NOT protect
> the component's style from the main site-css, if the site-css cascades
> into the candy. Which is exactly what what messed up my superfish
> menu.

There's no difference between adding an unique ID or using important,
it's just different specificity levels. !important won't protect the
"component's" style either, undeclared styles will cascade anyway.
What will "protect" the CSS is using widget-specific IDs and
classnames, with a prefix or whatever, to lessen the chance of
overriding it. It will never be fully "protected".

> "writing styles in-line (if it's not meant to be altered). If this has
> not been done it is indeed badly written code."
>
>      --i don't agree. one of the principals of best-practice web-
> styling is to NOT use inline styles, but to separate formatting out to
> a css file. that way, the web developer can tweak the formatting
> without touching the html structure.

I said "if it's not meant to be altered". If it's a copy & paste thing
there's no harm.

> "There is also a reason why !important is seldomly used: because it
> makes a mess of figuring out which style is being applied by
> overriding the cascading"
>
>      --i dont agree. the mess is what you have without !important. it
> instantly clears up that mess, because then you know exactly which css
> is controlling the candy-- the one with !important. override the
> cascading is exactly the benefit of using !important. The site-css was
> not designed to be compatible with your 3rd-party candy.
>
> i think the reason !important is seldom used, is because it's little-
> known, and because it's usually described as a way to resolve
> conflicts between web-page and browser-css (aka "author" vs "user").

It's not little known unless to those who are not web developers/
designers, that's basic stuff. If your widget declares !important on a
common class name that is used elsewhere in your page, there goes your
'solution'.

> "prepending the unique ID to every style is much better."
>      --Superfish does indeed use a unique ID. as Klaus points out,
> that does not insulate Superfish from the site-css.

Nothing will "insulate" it. You must have noticed that all of
Superfish styles are prefixed by "sf-". They will only be overriden if
you're not sensible with your own CSS, I bet your page has lots of ID
specified styles for containers.

> for me, the proof is in the pudding. My silverfish displayed all wrong
> without !important. It displays beautifully WITH !important. That's
> all the proof i need!

Good to know. Just don't go out shouting that your solution is perfect
for every situation - I'm sure you'll find that out by yourself.

> "a 3rd party widget...should...use...important declarations.
> Nevertheless there is no guarantee that the site's CSS will not
> override styles."
> --why? unless the site css ALSO uses !important, how else could it
> override the candy-css?

exactly.

over and out,
- ricardo

Reply via email to