Applying a style sheet only to a single div

Discussion in 'HTML' started by russell.allbritain@gmail.com, Apr 19, 2007.

  1. Guest

    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?
     
    , Apr 19, 2007
    #1
    1. Advertising

  2. Desmond Guest

    On 19 Apr, 19:28, wrote:
    > 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.
     
    Desmond, Apr 19, 2007
    #2
    1. Advertising

  3. russell.allbritain wrote:

    > 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!
     
    Toby A Inkster, Apr 20, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    531
  2. Tatyana
    Replies:
    2
    Views:
    505
    Tatyana
    Aug 25, 2006
  3. Orgun
    Replies:
    6
    Views:
    359
    H. S. Lahman
    Sep 26, 2006
  4. brm6546545
    Replies:
    1
    Views:
    1,038
    Jukka K. Korpela
    Apr 19, 2007
  5. Replies:
    9
    Views:
    160
    Randy Webb
    Dec 30, 2004
Loading...

Share This Page