inherited styles

Discussion in 'HTML' started by jb, Mar 9, 2006.

  1. jb

    jb Guest

    If there is a style that looks like this:
    ..border_color {border-color: #000000;}

    Can another style be created which inherits border_color in its entirety?

    something like...
    ..top_border {border-top: 1px solid; border_color: inherit}

    I know color: can be inherited, but can a whole style?
     
    jb, Mar 9, 2006
    #1
    1. Advertising

  2. jb

    Toby Inkster Guest

    jb wrote:

    > Can another style be created which inherits border_color in its entirety?


    Nope -- not the way you mean. CSS inheritance works differently from
    object-oriented inheritance.

    If you want to reuse colours and other styles over several different
    classes, you might want to look into using a server-side scripting
    language to serve your CSS.

    e.g.

    <?php
    header("Content-Type: text/css");
    $headingHighlight = '#ccffcc';
    $normalForeground = '#006600';
    ?>
    H1 {
    border-left: 0.67em solid <?=$headingHighlight?>;
    border-bottom: 2px solid <?=$headingHighlight?>;
    padding: 0.25em;
    }
    H2 {
    background: <?=$headingHighlight?>;
    color: <?=$normalForeground?>;
    padding: 0.25em;
    }

    and so on.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Mar 9, 2006
    #2
    1. Advertising

  3. jb

    jb Guest

    > jb wrote:
    >
    >> Can another style be created which inherits border_color in its entirety?

    >
    > Nope -- not the way you mean. CSS inheritance works differently from
    > object-oriented inheritance.
    >
    > If you want to reuse colours and other styles over several different
    > classes, you might want to look into using a server-side scripting
    > language to serve your CSS.
    >
    > e.g.
    >
    > <?php
    > header("Content-Type: text/css");
    > $headingHighlight = '#ccffcc';
    > $normalForeground = '#006600';
    > ?>
    > H1 {
    > border-left: 0.67em solid <?=$headingHighlight?>;
    > border-bottom: 2px solid <?=$headingHighlight?>;
    > padding: 0.25em;
    > }
    > H2 {
    > background: <?=$headingHighlight?>;
    > color: <?=$normalForeground?>;
    > padding: 0.25em;
    > }
    >
    > and so on.
    >


    It seems like a glaring omission.
     
    jb, Mar 9, 2006
    #3
  4. Jukka K. Korpela, Mar 12, 2006
    #4
  5. jb

    Toby Inkster Guest

    Jukka K. Korpela wrote:
    > jb <> wrote:
    >
    >> It seems like a glaring omission.

    >
    > That's mainly because you haven't studied CSS.


    I dunno. I think a way of defining a few constants, particularly for
    colours could be handy, as sometimes certain values need to be reused, in
    ways that CSS inheritance can't deal with. Something like...

    @define "mainbg" "white";
    @define "pale" "#efe";
    @define "medium" "#9c9";
    @define "dark" "#393";
    @define "mainfg" "black";

    BODY {
    color: def("mainfg");
    background: def("mainbg");
    }
    H1 {
    color: def("dark");
    background: def("mainbg");
    }
    H2 {
    color: def("mainfg");
    background: def("pale");
    }
    ..sidepanel {
    color: def("mainfg");
    background: def("pale");
    float: left;
    width: 25%;
    border: medium double def("medium");
    }
    ..specialbox {
    color: def("mainbg");
    background: def("medium");
    border: medium double def("dark");
    }

    It would make it really easy to change a site's colour scheme without
    changing the rest of the styles.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
     
    Toby Inkster, Mar 12, 2006
    #5
  6. Gazing into my crystal ball I observed Toby Inkster <usenet200603
    @tobyinkster.co.uk> writing in news:5n.co.uk:

    > I dunno. I think a way of defining a few constants, particularly for
    > colours could be handy, as sometimes certain values need to be reused, in
    > ways that CSS inheritance can't deal with.


    I absolutely agree with you. I'm working on a site for my church, and the
    colors are following the liturgical seasons. There are five colors: white,
    red, pink, purple and green, so that would be a great feature.

    --
    Adrienne Boswell
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
     
    Adrienne Boswell, Mar 12, 2006
    #6
    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. Phil S.

    Styles missing after upgrade

    Phil S., Jul 8, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    321
    Phil S.
    Jul 8, 2003
  2. Gandalf
    Replies:
    3
    Views:
    646
    Gandalf
    Jul 18, 2003
  3. Scott
    Replies:
    0
    Views:
    407
    Scott
    Jul 27, 2003
  4. Kornél Pál
    Replies:
    2
    Views:
    1,626
    Kornél Pál
    May 11, 2009
  5. 7stud --
    Replies:
    11
    Views:
    411
    7stud --
    Nov 9, 2007
Loading...

Share This Page