0

I had a style.css file for my existing web pages. Then I created some new webpages with internal style sheet. But the new pages were not displayed according to the internal style sheets. When I move those pages to a new web application, they work fine.

I also tried to create an external style sheet for new pages with style.css and included that. However still the new pages were not displayed accordingly.

Can anyone tell me what might be the issue? Does style.css override the internal style sheet or other css?

user1247412
  • 647
  • 7
  • 16
  • 29

2 Answers2

2

No style.css does not override other styles. CSS decides which styles to apply to an element based on specificity.

CSS Specificity is a somewhat large, but important topic. Read about it here:

CSS Specificity: Things You Should Know

Edit

For equal specificity, the last defined style is used.

Ayush
  • 41,754
  • 51
  • 164
  • 239
  • Not just based on specificity... cascading is a larger topic, of which specificity is but just one part. – BoltClock Nov 12 '12 at 06:30
  • However I am not able to figure out why it is not behaving according to style1.css when I have included only style1.css in that file.. – user1247412 Nov 12 '12 at 06:52
1

its depend on the precedence and how you are using form example style.css is at the last of all css than it will override or you have used !important

Good read

  1. CSS precedence
  2. 6 Assigning property values, Cascading, and Inheritance
  3. Understanding Style Precedence in CSS: Specificity, Inheritance, and the CascadeCSS precedence
  4. Specifics on CSS Specificity
Community
  • 1
  • 1
NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
  • @user1247412 i mean if you have incliuded style.css at the end of css file like ... than the thing in style.css will be higher precedence – NullPoiиteя Nov 12 '12 at 06:28
  • @NullPonter: I have not included style.css in my new files. But I am not able to see changes according my internal style sheet. When I move that web page to a new web project, I do see the changes... – user1247412 Nov 12 '12 at 06:32