Applying a style sheet only to a single div

R

russell.allbritain

I am developing a custom content management solution for a client. I
was wondering if there was a way to allow them to maintain a style
sheet that would only affect only a certain DIV. I know you could make
the div a class or make my style sheet take precedence, but they could
still affect anything I haven't implicitly defined in my style sheet.
I'm no so worried about them intentionally changing anything but they
could accidentally affect other parts of the page unknowingly

any ideas?
 
D

Desmond

I am developing a custom content management solution for a client. I
was wondering if there was a way to allow them to maintain a style
sheet that would only affect only a certain DIV. I know you could make
the div a class or make my style sheet take precedence, but they could
still affect anything I haven't implicitly defined in my style sheet.
I'm no so worried about them intentionally changing anything but they
could accidentally affect other parts of the page unknowingly

any ideas?

This is easy every DIV can have it's own style. A dive will have a
unique ID

<head>
<LINK href="holclub.css" type=text/css rel=stylesheet>
</head>

<DIV id=PageContent>


*** In the style sheet ****

#PageContent
{
position:absolute;
font-family:verdana,helvetica,arial;
font-size: 14px;
position:absolute;
left:150px;
width:600px;
top: 106px;
height:360px;
border-width: 0px;
border-style:solid;
margin-top:5px;
margin-left:5px;
}

Hope this helps.
Dssmond.
 
T

Toby A Inkster

russell.allbritain said:
I am developing a custom content management solution for a client. I
was wondering if there was a way to allow them to maintain a style
sheet that would only affect only a certain DIV.

Not in current versions of HTML. WHATWG HTML 5 offers this facility, and
parts of HTML 5 (IIRC, not this part yet though) are being currently
implemented in newer versions of Safari, Firefox and Opera.

If you allow them to write their own style sheet, you could try having
your CMS parse that style sheet and adjust the selectors so that they only
apply to that DIV. For example, if they input the following style sheet:

body { color: orange; }
p { margin: 1em 0 2em; }
h1, h2, h3 { color: green; }

Your CMS could transform it to:

#somediv { color: orange; }
#somediv p { margin: 1em 0 2em; }
#somediv h1, #somediv h2, #somediv h3 { color: green; }

I'm not going to pretend that it would be easy; but it wouldn't be
impossible.

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top