#1
  1. Sockless.net
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Purmerend, the Netherlands
    Posts
    33
    Rep Power
    11

    Question Override embedded CSS with linked CSS?


    Hi can anyone tell me if I can override embedded CSS with a linked stylesheet?

    Here is what I want to change:
    Code:
    <col width="40%" style="background-color:#EEEEEE;text-align:left;">
    I want to change the background-color without changing anything in the above mentioned code, this means I want to change it with an extern stylesheet.
    Last edited by dwightjelee; February 18th, 2004 at 04:55 AM.
  2. #2
  3. a rootin', tootin', shootin'
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Feb 2004
    Location
    location.href="hame"
    Posts
    3,475
    Rep Power
    100
    you want to use js, not css for this.

    basically, call a js function like this one:

    function chgCss(objId)
    {
    document.getElementById(objId).style.backgroundColor = "#333" ;
    }

    nice and easy, m8
  4. #3
  5. Sockless.net
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Purmerend, the Netherlands
    Posts
    33
    Rep Power
    11
    Ok little confused now

    I don't really get it anymore, should I put that in my CSS or in my HTML?

    Pleaze advise
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,009
    Rep Power
    2791
    Place the external CSS link below the inline CSS.
  8. #5
  9. Sockless.net
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Purmerend, the Netherlands
    Posts
    33
    Rep Power
    11
    Ehm.... I forgot to say that I can't change anything in my HTML page, I don't have permission for this.
    The page is been requested from a company's server, this company want me to change the layout. But the only thing I have permission to change is the extern CSS file

    If I would have permission to change the HTML page I would have been done already
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2003
    Posts
    288
    Rep Power
    12
    Or try using the !important setting on your property within your css selector in your linked style-sheet.

    Hope that helps,

    -D
  12. #7
  13. a rootin', tootin', shootin'
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Feb 2004
    Location
    location.href="hame"
    Posts
    3,475
    Rep Power
    100
    inline css always overrides external stylesheets. basically, given the the html you've shown and that you cannot change it, you're not gonna be able to change the styles of specific elements, only generically.

    in an external stylesheet, you can write:

    col{background-color: #333 !important}

    but that would change all elements of that type, not a specific one.

    basically, you'll need access to the html to make any proper changes.

    btw: never use inline or head based styles. always use class names linked to external stylesheets. that way your site is more easily configured.
  14. #8
  15. Sockless.net
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Location
    Purmerend, the Netherlands
    Posts
    33
    Rep Power
    11

    Talking


    Thanks a lot man! It worked out just fine
    I've been strugling for 2 days on this code

IMN logo majestic logo threadwatch logo seochat tools logo