在HTML页面中加载CSS文件的顺序是什么? [英] What is the order of loading the CSS files in a HTML page?

查看:276
本文介绍了在HTML页面中加载CSS文件的顺序是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在HTML页面中加载CSS文件的顺序。

I want to know the order of loading the CSS files in a HTML page.

我的实际需求是这样的:我有超过10个CSS文件应用程序。

My actual requirement is like this: I have more than 10 CSS files in my application.

我在每个HTML页面中导入了大约3到4个CSS文件。问题是我有重复的类,在一些CSS文件中定义。这意味着我覆盖CSS文件中的一些CSS类。
在某些页面它的行为正确。在某些页面中它的行为是错误的。我有为HTML页面中的一些DIV定义的内联样式。我也保留那个DIV的CSS类。

I am importing some 3 to 4 CSS files in each HTML page. The problem is I have duplicate classes that defined in some CSS files. That means I override some of the CSS classes in the CSS files. In some pages it behaves correctly. In some pages it behaves wrongly. I have inline styles defined for some of the DIVs in HTML page also. I am keeping CSS class for that DIVs also.

任何人都知道哪个优先级更高或哪个先加载?

Can anyone know which one will take higher priority or which one loads first ?

推荐答案

通常最后一条规则优先。据说,有异常,因为内联样式优先于外部样式表(内联!重要比外部!重要,等等),更具体的选择器覆盖通用选择器。

Generally the last rule takes precedence. With that being said, there are "exceptions" in that inline styles take precedence over external stylesheets ( an inline !important is more important than an external !important, etc ), and more specific selectors override generic selectors.

阅读全部内容@ http:// www。 w3.org/TR/CSS2/cascade.html

这篇关于在HTML页面中加载CSS文件的顺序是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆