Cache issue.
Try changing
<link rel="stylesheet" href="index.css">
to
<link rel="stylesheet" href="index.css?v=<?php echo time(); ?>">
This will force the CSS to reload.
Answer from Dampen59 on Stack OverflowCache issue.
Try changing
<link rel="stylesheet" href="index.css">
to
<link rel="stylesheet" href="index.css?v=<?php echo time(); ?>">
This will force the CSS to reload.
So I had this problem that my CSS code was working fine but when I deleted or added something it did not change on the site and I found a pretty easy solution for this that worked for me:
Just press: Ctrl + F5
This is called a "hard refresh" it worked for me on Windows, and with Chrome browser, if you use something else try this site: link
This is a little bit old question but I got the same problem now and I figured maybe I can help someone.
Videos
From you comments on existing answers, it doesn't look like something we could find out based on the provided code. Here are a couple of things that could help you diagnose the problem though.
In your browser, open up developer tools. (For Firefox, get Firebug and hit F12, For Chrome or Opera, just hit F12 for the built in tools.)
Then you want to open up the network tab ('Net' in Firebug, 'Network' in Chrome)
Once you have that open, reload the page and look at the server requests. One of them will be for your CSS file. What you want to look for is the HTTP status. If that Status is anything starting with a 4, you've got trouble. Either it's a 403 which means you don't have the correct permissions to load the file, or you'll have a 404, as we all know, 'not found', which would indicate that your URL is faulty.
Another way to quickly find out whether the file is actually loading is to view the source of the page in the browser, and click the link to the CSS file. In Firefox, doing that makes the source viewer load the contents of the CSS file instead. If that doesn't work out, you also get an idea that it can't be accessed. It's worth noting that the first method will make it clearer what exactly the issue is though.
Most likely I assume you have a typo in your capitalisation of the file name or path. If it is hosted on a non-windows server, that almost certainly makes a difference.
The <link> tag should be within your <head> tag, also consider using absolute "/" path rather than relative if you have sub directories.
Cache issue.
Try changing
<link rel="stylesheet" href="index.css">
to
<link rel="stylesheet" href="index.css?v=<?php echo time(); ?>">
This will force the CSS to reload.
So I had this problem that my CSS code was working fine but when I deleted or added something it did not change on the site and I found a pretty easy solution for this that worked for me:
Just press: Ctrl + F5
This is called a "hard refresh" it worked for me on Windows, and with Chrome browser, if you use something else try this site: link
This is a little bit old question but I got the same problem now and I figured maybe I can help someone.
Although the link to the CSS file is in one of your included files, that part of the code is included in / becomes part of the main page file/s, which is/are in the root directory, therefore the CSS file is referenced from there (i.e from the root directory). So, instead of this
<link rel="stylesheet" href="../css/stilmall.css" type="text/css">
you have to put this in your header.phpfile:
<link rel="stylesheet" href="css/stilmall.css" type="text/css">
which is the proper filepath from the root directory.
But my CSS file isn't applying the changes to the files properly and I cant seem to find the issue.
Sounds like a caching issue to me, recaching it can be as easy as:
<link rel="stylesheet" href="../css/stilmall.css?<?php echo time(); ?>" type="text/css">
This reads the CSS file will be read over and over for ever millisecond ran (by time of constructing the HTML page)
Final answer. The issue has been fixed through comments of main post:
There was an issue with both caching, file directory and CSS properties. Float was used but would not have a visual impact, instead- using background confirmed that everything's working fine.
I recently made a website locally. A PHP file, a CSS file and then another PHP file to handle the database actions (which was to be activated later after it was moved to a server).
When I made the website locally, my CSS file was successfully updating the apperance of my index.php file.
I then moved all these files to a local server folder and that's when it started to act funny. It seems like my index.php file is using the CSS file because its background is still black. However in my CSS file, when I change the background color from black to any other color, the website still remains black. Its not detecting any changes in the CSS file.
But when I deliberately mispell the name of the CSS file in the stylesheet link in my index.php, the website turns default white. Which means it is succesfully using that file to get the black background.
What is going on!? In my index.php, I used an include statement to to include the other PHP file that handles the database actions. Everything is working fine, but modifying the CSS file is not having any effect on the website.
LPChip suggested me to use the debugger/inspector of Firefox and there, the head is greyed out. On further investigation, I noticed it said "css was not loaded because its mime type "text/html" is not "text/css"
That made me check something...
I got the solution:
I had an apache mod_rewrite activated. While the path was correct, it seems that this mod_rewrite or the dedicated php for the redirection somehow told the browser that the file was html not css.
I had a similar issue. Was setting up a NGINX from scratch and all the styles for my project were not applied. But they existed and I did not had any other error.
I found out that I had to apply the correct mime types to all files served by NGINX. Before the fix it was text/plain and this did not worked.
I fixed it by adding those lines to NGINX configuration:
http {
# other config before ...
include /etc/nginx/mime.types;
default_type application/octet-stream;
# rest of config ...
}
Try removing the leading slash. The leading slash indicates that the path starts at the website's root, which might not be the "Source Files" directory.
In other words, use css/reset.css instead of /css/reset.css.
You forgot to close your <meta> tags (use <meta ... /> with the slash before the >). So a browser is allowed to ignore anything after <meta content="IE=8" http-equiv="X-UA-Compatible"> as it does not belong inside <meta> tag.
However, since browsers are usually able to understand crappy HTML, it might not be the cause of your problem. Are you sure the CSS stylesheets are loaded from the correct URL? Test if http://yourdomain/css/reset.css actually exists. You might also simply want to remove the leading slash in the stylesheet URLs.
I have tried to create WordPress theme using your functions.php, style.css and index.php and for me, the stylesheet is loading correctly. Please make sure you have added your header.php and footer.php for the theme. Please study some tutorials for theme development on WordPress.You can look at this link https://codex.wordpress.org/Theme_Development for detailed information.
It turns out there was nothing wrong with my code. The problem lies in the browser (Chrome) not refreshing the css styles. I initially thought the stylesheet was not loading, but in fact the browser was simply needing a refresh. The solution is to force a cache refresh by typing Ctrl + F5. Thanks to all of you for the help!
Works fine for me ^^
Use this syntax:
cssman.php
<?php
ob_clean();
header('Content-Type: text/css');
header('Cache-Control: no-cache, must-revalidate');
error_reporting( 0 );
// These are just to show you can use dynamic values and such:
$type = isset($_GET['type']) ? $_GET['type'] : '';
$theme = isset($_GET['theme']) ? $_GET['theme'] : '';
/** Simply print or echo your css here **/
ob_end_flush();
?>
Try your output first, by navigating to the .php file manually. If there is no content at all, there is most likely a mistake in the PHP code, for debugging you could add error repporting (don't forget to also ini_set('display_errors',1), else errors will only be logged).
Then add it to your view:
your view
<style type="text/css">
@import "/Library/Stylesheets/cssman.php?type=cms" screen;
/* any aditional files here aswell */
</style>
you can do it like
echo"
<style>
h1#foo {
color: ".$asd.";
}
</style>
";
Hello guys I made a project for uni and The problem I just can’t solve is that whenever I open an html or a php file from localhost The style.css never displays... howevee if I doubleclick the .html file it pops up in the browser with the style.css design! What can I do to solve this problem? Thanks!