#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    Galway, NY
    Posts
    189
    Rep Power
    14

    CSS Question: Is this legit / supported / compliant?


    I'm wondering if duplicate / overriding directives are allowed in the CSS Spec.
    Here's an example:
    Code:
    <div style="background-color: black; background-color: white">
    will the second call to background-color override the first and be drawn as white?

    it may sound stupid, but i'm writing a PHP class that outputs CSS and I don't want to have to do pattern matching to make sure that the user inputted tag isn't already set. I want to just append it.
    -Paul Wieland_____________
    http://www.sickdimension.com
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2004
    Posts
    1
    Rep Power
    0
    i know it's not legit and i think it could cause problems bij some browsers rejecting the css
  4. #3
  5. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    The CSS validator at w3c.org does not return an error nor a warning when you re-declare a style like you have.
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    Galway, NY
    Posts
    189
    Rep Power
    14
    interesting...
    i thought i read somewhere a long time ago about the proper way to override a style by re-declaration, but i think it had something to do with using linked style sheets and embedded sheets in the header. It didn't mention anything about doing it inline like I have here.
    -Paul Wieland_____________
    http://www.sickdimension.com
  8. #5
  9. Über nübe
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Location
    Babylon 4
    Posts
    240
    Rep Power
    12
    You don't want to use JavaScript to set the style?
    Hello, old friend...
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2001
    Location
    Galway, NY
    Posts
    189
    Rep Power
    14
    i came up with a pretty basic solution. i just split the tags by ; and then again by :. That gave me a keyed array an consequently weeded out the duplicates.
    -Paul Wieland_____________
    http://www.sickdimension.com

IMN logo majestic logo threadwatch logo seochat tools logo