简体   繁体   中英

Does style.css override other CSS file classes and ids

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM