I have a webpage with the following CSS style that overrides some higher level styles.
#pnlActions {
background-image: -webkit-gradient(linear,left top,left bottom,from(#000),to(#000));
background-image: -webkit-linear-gradient(#000,#000);
background-image: -moz-linear-gradient(#000,#000);
background-image: -ms-linear-gradient(#000,#000);
background-image: -o-linear-gradient(#000,#000);
background-image: linear-gradient(#000,#000);
}
The odd thing is that the first time I load the page, the styles are completely ignored until I refresh the page - then the styles are applied. Then I'll quit the browser, load the page again and the styles are no longer applied (until I refresh the page).
I can tell all this from chrome/firefox/ie browser tools.
I am at a complete loss to explain why this is happening. Any ideas?
Make sure that you add the rel attribute to the link tag When you add an external CSS file to your HTML document, you need to add the rel="stylesheet" attribute to the <link> tag to make it work. If you omit the rel attribute from the <link> tag then the style won't be applied to the page.
Browser Cache If you are adding/modifying in-line CSS or JavaScript and not seeing the changes reflected in the HTML source, the page is likely being cached. The solution may be to purge the WordPress object cache, which stores our page caching (Batcache) renders.
Anytime you make changes to CSS, JavaScript and are viewing the page you've updated - you will see this concern. You can force a refresh by pressing CTRL+F5 on the browser and that will get the latest version.
Style rules take precedence in right-to-left order. Rules to the right take precedence over rules to the left. Properties that are not declared are carried over and reapplied to succeeding style sheets.
A couple of years later, but this is how I solved it.
For some reason having the STYLE inside the HEAD tag (Internal CSS) was only working after a refresh.
But adding it as a LINK (External CSS) solved it. Now it works from the first run.
Inside the CSS I added !IMPORTANT to the styles because I needed to override some other elements, just like the OP.
For those who have doubts on how to add Internal or Extenal CSS, please check this link.
Try appending the following php code to your .css file in the header. Your file must have the extension of .php for this to work.
<link rel="stylesheet" type="text/css" media="screen" href="your.css?<?php echo time(); ?>" />
That will rule out caching of the style sheet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With