0

I know this is a simple question but for some reason I'm wondering if I'm doing something wrong here.

My understanding is that if you declare 2 CSS files

<script type="text/css" src="JQueryUI.css"></script>     
<script type="text/css" src="Override.css"></script>  

I want to use the "Override.css" to override some values, so if I type let's say ".ui-accordion" and put my own values, i would expect them to take priority over the original values located under that name on the JQuery.css file.

Mainly because the declaration states that Override.css comes AFTER JWuery.css.

For some reason this is NOT happening.

I tried switching the declaration of the 2 files
...but the Jquery.css seems to ALWAYS seems to take priority.

Any reason why ??

6
  • 2
    The selectors in jQueryUI.css may have a higher specificity. Have a look at this link. Commented Aug 7, 2012 at 0:26
  • OK...do you know how to change that and simply tell "anything on my override.css" file has higher specificity than ... ? Commented Aug 7, 2012 at 0:30
  • You would actually have to give your selectors in your Override.css file a higher specificity. Or, give your Override.css file the exact same selectors as your JQueryUI.css file, and make sure Override.css is loaded after JQueryUI.css. Another option is to use !important, which would be the "quick and dirty" way of doing it (not recommended). Commented Aug 7, 2012 at 0:34
  • this is the 1s time i hear about Specificity. Not sure how to specify a higher one on the Override.css element (or event better on the entire file). Regarding loading, isn't it enough to specify it after on the declaration ? Commented Aug 7, 2012 at 0:41
  • btw are you really using <script> tags to attach CSS files? Has it ever worked? Commented Aug 7, 2012 at 0:45

2 Answers 2

3

This is not working because you are not loading correctly the css files.

It should be:

<link rel="stylesheet" href="JQueryUI.css" type="text/css" media="all" />
<link rel="stylesheet" href="Override.css" type="text/css" media="all" />
Sign up to request clarification or add additional context in comments.

Comments

2

I am agree with Zhihao about specificity of elements, but I have also noticed that your are using <script> to attach CSS files, use <link> tags instead, maybe that would load your css and it will override existing styles:

<link rel="stylesheet" type="text/css" href="JQueryUI.css" />
<link rel="stylesheet" type="text/css" href="Override.css" />

P.S. just posted my notice in the comment as an answer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.