SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Undo/cancel/revert a style declaration

    Hi,

    Is it possible to 'cancel' a style declaration using CSS? I realise the question is vague, so here's an example:

    I have a CSS file containing the following rules (obviously this isn't my actual problem!)
    Code CSS:
    p { color: white }
    span { color: red }
    and some HTML that looks like this:
    Code HTML4Strict:
    <p>I am in white <span>but I am in red</span></p>

    I am not allowed to change the CSS file as it is locked down by a software vendor, so all I can do is embed style rules in the page. What I want to do is cancel the span rule so that the text now picks up the paragraph rule instead and all the text is white. The thing is, the supplied CSS file might be changed by the vendor and the paragraph colour declaration could change to green instead of white, so I don't just want to put
    Code CSS:
    span {color: white; }
    in my embedded style.

    Is this sort of thing possible?

    Many thanks,

    Andrew

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    8,897
    Mentioned
    138 Post(s)
    Tagged
    2 Thread(s)
    Try span {color: inherit; }
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Member
    Join Date
    Dec 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That works great, thanks very much. I wasn't expecting it to be that simple

  4. #4
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    span { color:white } would have worked too.

    One of the beauties of CSS is that if you declare the same value again, it overrides the previous declaration... which is why source-order and load-order are so important.

  5. #5
    Mouse catcher silver trophy
    Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,829
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by deathshadow60 View Post
    span { color:white } would have worked too.
    Right up until the point where p {color:white;} was changed to p {color:green;} ... then the span is still white rather than taking the same colour as the paragraph.


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
  •