I’m creating a kind of CMS. In this system, each editor can define their own CSS like below.
This style should be applied to their own articles.
<style>
p{
color:blue;text-align:center;
}
a{
color:red;
}
</style>
These styles must be applied to a particular div, in this case id="editors_area".
<body>
<div id="editors_area">
===Styles should be applied only here.===
Each editors article are displayed in this area.
</div>
===Styles should NOT be applied here.===
</body>
To achieve this, I have a plan to insert #editors_area into editor’s CSS, as a descendant selector on serve side like below.
<style>
#editors_area p{
color:blue;text-align:center;
}
#editors_area a{
color:red;
}
</style>
But I guess there are more simple ways to achieve above requirement.
EDIT
I deleted the javascript code. Which was not suited here.
Any idea will be appreciated.
Thanks in advance.
SASS and SCSS give you the ability to do stuff like this (unless I’m totally missing the point of you’re question, which is possible as I’m about as far as you get from a front end person).
Something like:
Depending on what language you’re working in, it might be worth checking out. I’ve seen implementations for Ruby, Python, PHP and Java, although I’ve only used Ruby’s myself.