As previously mentioned in my comment, it appears to be a typical situation of "CSS overwrite". One technique to prevent this is by utilizing the CSS property !important
to specify to the browser which CSS rule should take precedence and not be overridden.
For instance: color: purple !important;
CSS implements styles based on the order they are loaded. If you have one CSS file with x rules and a second CSS file with y rules targeting the same elements, the last loaded CSS file will usually overwrite the styles of the preceding one.
This sequence is referred to as the top-down rule, and can only be superseded by the !important
property and in-line CSS. The !Important
property typically overrides any in-line CSS.
Understanding the concept of the top-down rule, if you have the ability to modify the CSS and/or control the loading order of CSS files, you can ensure that your own CSS rules are applied by arranging for them to be loaded as the final included file in your project.
For example:
<head>
<link rel="stylesheet" type="text/css" href="loadedfirst.css">
<link rel="stylesheet" type="text/css" href="loadedsecond.css">'
<link rel="stylesheet" type="text/css" href="loadedlast.css">
</head>
If these 3 files contain rules affecting the same elements, the loadedlast.css file is the CSS that will prevail over the previous ones, except when using the !important
property and in-line CSS. By managing the sequence of your CSS files, you can avoid the need for employing techniques like relying on the !important
property.