CSS on code tag?

  • Unknown's avatar

    Hi!

    I have been playing with the idea to use custom CSS and today actually took the decision to try it out before spending my money on it.

    My main issue is that I blog mainly with code snippets (I’m a programmer). Unfortunately it seems that custom CSS doesn’t allow me to change anything on the code tag..

    Is there a way to change the CSS on <code>?

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    It looks like you’re using the code shortcode, follow the links at the bottom of that page to the original syntax highlighter plugin author’s site for more information about how to style it with CSS. You could also use your browser inspector to see how the code is formatted.

  • Unknown's avatar

    Thanks for the fast reply. I think the problem is something else. For example I have this simple CSS to make everything red:


    * {
    background-color: red !important;
    color: red !important;
    }

    Everything gets red except my code snippet which I find weird.

    ![proof](http://s8.postimg.org/4hlbp0xd1/Screenshot_from_2014_11_08_17_55_23.png)

  • Unknown's avatar

    The CSS rule you’ve used as an example only works if there are no other rules more specific than it affecting any given HTML element. In this case the syntax highlighter CSS rules are more specific than the universal selector due to each one using at least one class.

    An example probably helps! Here are the rules that you can experiment with currently:

    .syntaxhighlighter .plain,
    .syntaxhighlighter .plain a {
      color:#f00!important;
    }
    
    .syntaxhighlighter .line.alt1 {
       background-color:#eee!important;
    }
    
    .syntaxhighlighter .line.alt2 {
      background-color:#ddd!important;
    }
  • Unknown's avatar

    That’s it! Although I developed web sites in the past I never came to this issue. I guess one learns something new every day :)

    Thanks a lot!

  • The topic ‘CSS on code tag?’ is closed to new replies.