|
Posted by Jukka K. Korpela on 04/19/07 22:13
Scripsit brm6546545:
> I know how IDs and classes work. but i guess i would like a style
> sheet to be edited by the user that cannot affect any other items on
> the page
That's not possible. If they can write anything into a style sheet, you
cannot prevent them from affecting all elements on a page. The "best" you
could do in that direction is that you could make the HTML code contain
<link> elements referring to their style sheet and your style sheet, in that
order, and declare as !important everything that you want to "force" upon
them. They could still beat your rules by using !important and more specific
selectors. Besides, how could you force your style rules on all elements
except one div? The answer is that you can't.
> I know they could do
>
> #PageContent table{
> border:solid 5px red;
> }
>
> but i don't want to give them the ability to mess up anything outside
> there "box"
Well, it's their site, isn't it? If you clearly specify that they must
precede all rules with #PageContent and explain why, then it's up to them
whether they mess up their site.
You could make things easier, though, by using a short id value. If they
need to prefix everything in a fixed way, the prefix need not be mnemonic;
it could be just #c for example - harder to mistype than #PageContent.
As a completely different approach, if you make the box content a separate
HTML document, embedded with <iframe> or <object>, you could make it use
their style sheet and yours and the embedding document your style sheet
only. That way, everything they set in their style sheet would affect the
box content only.
Embedding approaches have their drawbacks of course. In particular, the box
would have a fixed size and it might need its own scrolling mechanism.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
[Back to original message]
|