SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2002
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Assigning properties between CSS elements

    Hi,

    Is it possible in css to assign properties of one element to other?

    for example:


    .element_1{
    width:100%;
    color:#FF0000;
    }


    .element_2{
    font-family: Verdana;
    }

    Is it possible to assign element_1 to element_2 so that element_1 will be a reference?

    Thanks

  2. #2
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Hi,

    If you mean can you do something like this:

    .element_2{
    width:element1.width;
    }

    Then no its not possible. You may be able to do something similar using ie expressions but it will only work for ie.
    http://msdn.microsoft.com/library/de...dude061198.asp

    Paul

  3. #3
    SitePoint Enthusiast Gamblingharry's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you want the element_1 properties assigned to element_2? As well as the font-family property? If so you can just do:

    Code:
    .element_1, .element_2 {
        width:100%;
        color:#FF0000;
    }
    
    .element_2 {
        font-family: Verdana;
    }
    This is equivalent to:
    Code:
    .element_1 {
        width:100%;
        color:#FF0000;
    }
    
    .element_2 {
        width:100%;
        color:#FF0000;
        font-family: Verdana;
    }
    so you are effectively just copying the element_1 attributes to element_2, without having to put all the extra code in.

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2002
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Paul O'B & Gamblingharry

    Gamblingharry that is exactly what I looking for

    Thanks

  5. #5
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Do you want the element_1 properties assigned to element_2? As well as the font-family property? If so you can just do:
    Good job someone's on the ball


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •