Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7929745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:11:26+00:00 2026-06-03T20:11:26+00:00

I have defined a class in my main.css file. .red { color: #d14; }

  • 0

I have defined a class in my main.css file.

.red {
  color: #d14;
}

And using it like this.

<div class="navbar">
    <div class="navbar-inner">
       <ul class="nav">
          <li class="active red">
             <a href="/admin/list"><i class="icon-leaf icon-white"></i>Admin</a>
         </li>
       </ul>
    </div>
</div>

Besides my main.css I also import the twitter bootstrap css file.

This way it does not work. Is it because Bootstrap is overruling my color definition?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T20:11:28+00:00Added an answer on June 3, 2026 at 8:11 pm

    The only element in your markup that could visually apply this style is the <a>, and that element has a lot of really specific CSS rules applied to it by Twitter Bootstrap, stuff like this:

    .navbar .nav .active > a,
    .navbar .nav .active > a:hover {
        color:#FFFFFF;
    }
    

    You’ll have to write something even more specific to get the style to apply:

    .navbar .navbar-inner .nav .red a {
      color: #d14;
    }
    

    Demo: http://jsfiddle.net/pYGaG/

    You could use !important on the rule if you really had to, but I really feel that you should avoid it as much as possible. If this is a single element that has this style, consider adding an id to it, which carries a lot of weight specificity-wise:

    <li class="active" id="home_link">
       <a href="/admin/list"><i class="icon-leaf icon-white"></i>Admin</a>
    </li>
    
    #home_link a {
      color: #d14;
    }
    

    http://jsfiddle.net/pYGaG/1/

    Here are a couple good articles on CSS specificity:

    • http://css-tricks.com/specifics-on-css-specificity/
    • http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html

    And as a side note, try to avoid presentational class names like red. Use more meaningful ones that aren’t tied to the way it should look, but what it is (for example, .active-link).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a template class defined in a header file like this. Here I
I have a class defined like this, with the appropriate getter and setter methods...
I have a DIV container that is a CSS class defined on the top
I have been reviewing some code that looks like this: class A; // defined
I have defined a div with the following: #main-alt-2 a:link {color:#39c;} #main-alt-2 a:visited {color:#39c;}
I have a template class defined like so: template <class T> class Command {
I have a class defined like so: public class Test { static <T> List<Class<T>>
I have defined a -main function in a :gen-class :main true namespace in Clojure.
I have defined an ArrayList in my main class where I am loading data
I have the next scenario: I define an int[][] variable in my main class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.