Can a CSS class inherit properties from another CSS class?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bissatch@yahoo.co.uk

    Can a CSS class inherit properties from another CSS class?

    Hi,

    I would like to be able to create a CSS class that has all the same
    property values as another class but additional ones too. Instead of
    having to rewrite the same property values again, can I simply request
    that the second class inherits all the values from the first one and
    then only have to write the additional properties. For example:

    ..fancyTable {
    border-top: 1px solid #000;
    border-right: 1px solid #000;
    }
    ..fancyTable td {
    border-bottom: 1px solid #000;
    border-left: 1px solid #000;
    }

    ..fancyTableWit hGreyBg {
    background: #eee;
    }

    Is there any way that I can allow fancyTableWithG reyBg to inherit the
    border properties (or any others that would have been declared) from
    fancyTable?

    As you can see, I have also set properties for <td> within
    fancyTableWithG reyBg. Will this be passed also to fancyTableWithG reyBg?

    If this method is supported, how well is it supported between browsers?

    Cheers

    Burnsy

  • Jim Royal

    #2
    Re: Can a CSS class inherit properties from another CSS class?

    In article <1140526035.702 739.213960@z14g 2000cwz.googleg roups.com>,
    <bissatch@yahoo .co.uk> wrote:
    [color=blue]
    > I would like to be able to create a CSS class that has all the same
    > property values as another class but additional ones too.[/color]

    Not precisely, but you can create two separate classes (.fancytable and
    ..greybackgroun d), and do this:

    <table class="fancytab le greybackground" >

    That will do what you want.

    --
    Jim Royal
    "Understand ing is a three-edged sword"
    Let me tell you a story. It’s about organizational incompetence and management fads, and it might help you recognize where your organization is sabotaging itself. Two years ago, I was doing the best work of my life. I had spent nearly a decade reshaping my career. I sharpened and blended my core skills into a vocation anchored at the crossroads of technical communication, scientific storytelling, and video production. I found a team of brilliant researchers who needed someone to share their work with the world, and I was a perfect fit. I wasn’t just part of a team; I had a mission. I was working at full throttle. I was proud. I was on fire. And then an ill-considered reorg took it all away.


    Comment

    • rwalrus

      #3
      Re: Can a CSS class inherit properties from another CSS class?

      Jim Royal wrote:[color=blue]
      > In article <1140526035.702 739.213960@z14g 2000cwz.googleg roups.com>,
      > <bissatch@yahoo .co.uk> wrote:
      >[color=green]
      > > I would like to be able to create a CSS class that has all the same
      > > property values as another class but additional ones too.[/color]
      >
      > Not precisely, but you can create two separate classes (.fancytable and
      > .greybackground ), and do this:
      >
      > <table class="fancytab le greybackground" >
      >
      > That will do what you want.
      >[/color]

      Pardon my ignorance, but is it legal for an element to have more than
      one class?

      --
      Ryan W

      Comment

      • Johannes Koch

        #4
        Re: Can a CSS class inherit properties from another CSS class?

        rwalrus wrote:
        [color=blue]
        > Pardon my ignorance, but is it legal for an element to have more than
        > one class?[/color]

        <http://www.w3.org/TR/html4/struct/global.html#ade f-class>

        --
        Johannes Koch
        In te domine speravi; non confundar in aeternum.
        (Te Deum, 4th cent.)

        Comment

        • Jim Royal

          #5
          Re: Can a CSS class inherit properties from another CSS class?

          In article <1140540282.476 429.186940@g47g 2000cwa.googleg roups.com>,
          rwalrus <rwsims@gmail.c om> wrote:
          [color=blue][color=green]
          > > <table class="fancytab le greybackground" >
          > >
          > > That will do what you want.
          > >[/color]
          >
          > Pardon my ignorance, but is it legal for an element to have more than
          > one class?[/color]

          Nope. Perfectly legal. And quite powerful when used sparingly.

          --
          Jim Royal
          "Understand ing is a three-edged sword"
          Let me tell you a story. It’s about organizational incompetence and management fads, and it might help you recognize where your organization is sabotaging itself. Two years ago, I was doing the best work of my life. I had spent nearly a decade reshaping my career. I sharpened and blended my core skills into a vocation anchored at the crossroads of technical communication, scientific storytelling, and video production. I found a team of brilliant researchers who needed someone to share their work with the world, and I was a perfect fit. I wasn’t just part of a team; I had a mission. I was working at full throttle. I was proud. I was on fire. And then an ill-considered reorg took it all away.


          Comment

          Working...