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 Overflow
๐ŸŒ
SitePoint
sitepoint.com โ€บ php
Css not loading with an include - PHP - SitePoint Forums | Web Development & Design Community
May 2, 2011 - I have a problem including a file which in itself has a css style this is my index file <?php require_once ('restricted/includes/configuration/conf.php'); include ($template); ?> In the above the conf.php <?php $teโ€ฆ
๐ŸŒ
Reddit
reddit.com โ€บ r/phphelp โ€บ php not identifying css files
Php not identifying css files : r/PHPhelp
October 16, 2024 - You need to explain that better, and also provide example code, and provide details about what you're actually seeing when you say it "fails" ... PHP and CSS are not related to each other. What you probably have is an issue with your HTML or URL to the CSS file.
Discussions

functions - CSS stylesheet not loading - WordPress Development Stack Exchange
This function will add the HTML markup to include your CSS file. ... I do have the wp_head() function in my header.php file, but maybe there's some other problem. I've edited my question above to include my header/footer code. Thanks. ... I have created a simple WordPress theme using your codes and i see that your style is working ... More on wordpress.stackexchange.com
๐ŸŒ wordpress.stackexchange.com
CSS file link is not working on PHP page - Stack Overflow
I have a Php page the code for which is below, I am trying to apply this signup.css but its not working. In PHP admin I can see the CSS shows up under Styles as SignUp.css, I have just placed this ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Can PHP files Interfere With CSS Files?
Sounds like a browser caching issue, clear your browser cache and see if it picks up the new changes (or go incognito) More on reddit.com
๐ŸŒ r/PHPhelp
8
2
April 1, 2021
Localhost not showing style.css
Share a snippet, there might be problem with specifying paths More on reddit.com
๐ŸŒ r/PHPhelp
23
1
May 27, 2021
๐ŸŒ
YouTube
youtube.com โ€บ watch
PHP #14 : My Css File Is Not Working In My Php Pages (Solved) - ุงู„ุฏุงุฑุฌุฉ ุงู„ู…ุบุฑุจูŠุฉ - YouTube
Hello everyone !!In this video inchaeAllah, we will learn how to solve a little problem that anyone can suffer from in his PHP projects related to CSS.The so...
Published ย  July 17, 2020
Top answer
1 of 3
12

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.

2 of 3
3

The <link> tag should be within your <head> tag, also consider using absolute "/" path rather than relative if you have sub directories.

Find elsewhere
๐ŸŒ
DaniWeb
daniweb.com โ€บ programming โ€บ web-development โ€บ threads โ€บ 437825 โ€บ css-not-working-from-header-php-include
html css - CSS not working from header.php include [SOLVED] | DaniWeb
October 22, 2012 - Quick check: view source on admin/index.php, click the stylesheet link, and confirm it loads. Also open DevTools Network tab and look for a 404 on the CSS request. ... Use a rootโ€‘relative or absolute URL for assets. Centralize a base path and reuse it in your includes. Example with a project base path (works whether you are in /admin, /include, etc.):
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 878156 โ€บ xampp-doesnt-load-edited-css-file
Xampp doesn't load edited css file. | Sololearn: Learn to code for FREE!
no thats not working. instead of that i found this and its working. <link href="style.css?v=<?php echo time(); ?>" rel="stylesheet" type="text/css" /> thanks for help Niush sitaula
๐ŸŒ
Reddit
reddit.com โ€บ r/phphelp โ€บ can php files interfere with css files?
r/PHPhelp on Reddit: Can PHP files Interfere With CSS Files?
April 1, 2021 -

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.

๐ŸŒ
Quora
quora.com โ€บ How-do-we-link-CSS-files-to-a-PHP-file
How do we link CSS files to a PHP file? - Quora
Answer (1 of 12): As mentioned three ways: version 1 : echo a snippet. [code]
๐ŸŒ
DaniWeb
daniweb.com โ€บ digital-media โ€บ ui-ux-design โ€บ threads โ€บ 479695 โ€บ external-style-sheet-not-working-in-html-php
web design - external style sheet not working in html/php [SOLVED] | DaniWeb
If you still see a 404 after these changes, post the page URL path (e.g., /website/pages/home.php) and the exact filesystem location of bground.css so we can map the paths precisely, @david.roun.7. If you use your browser's dev tools (typically by hitting the F12 key), you can click on the Console tab. If there are errors related to loading the external style sheet, the error will be listed there. โ€” JorgeM 958 Jump to Post ยท <link rel="stylesheet" type="text/css" href="bground.css"> A lot of times when that doesn't work for me, I would put the css file in a server and then rewriting it as: <link rel="stylesheet" type="text/css" href="http://yoursite.com/css/bground.css"> โ€” <M/> 170 Jump to Post
๐ŸŒ
Reddit
reddit.com โ€บ r/phphelp โ€บ localhost not showing style.css
r/PHPhelp on Reddit: Localhost not showing style.css
May 27, 2021 -

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!

๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 23373607 โ€บ css-doesnt-work-if-i-include-the-html-from-a-php
CSS doesn't work if I include the HTML from a PHP - Stack Overflow
April 15, 2021 - But the PHP file is in a different ... of the PHP file. ... The CSS doesn't work because your PHP script is in another directory from what the HTML you're including is....
Top answer
1 of 3
3

I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.

For a theme, see example

function add_styles() {
    wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );


For a plugin, see example

function add_styles() {
    wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );


For both, add an external URL:

function add_styles() {
    // Add Google Fonts
    wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
2 of 3
1

I'm glad to know that you are having fun learning and building your own websites.

Here is the deal: get_stylesheet_uri() function returns the current theme stylesheet. It adds the style.css file from your current theme directory.

The solution: If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().

Your code should be like this:

function fearnothing_script_enqueue(){
    wp_enqueue_style("style",  get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');


}

add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');

get_template_directory_uri() function Retrieve theme directory URI. For more information, you might take a look on codex documentation here

๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ functionsphp-not-loading-css-or-js
Functions.php not loading css or js? (Example) | Treehouse Community
March 26, 2016 - I did notice one thing however. Your URLs have a version number attached to them and you probably want to get rid of these, Put the following code into your functions,php file. There's a nice little that'll take care of this for you. Paste it right in. See if that helps :) https://www.codementor.io/tips/8369241717/remove-version-number-from-css-js-in-wordpress-theme ... Fixed: Added the following and it worked a treat.
๐ŸŒ
Quora
quora.com โ€บ Why-does-styling-the-UL-in-CSS-not-work-on-PHP-but-work-on-HTML
Why does styling the UL in CSS not work on PHP but work on HTML? - Quora
Answer (1 of 2): Modern web browsers, also referred to as a client, only understand 3 basic technologies: 1. HTML/Plain Text 2. CSS 3. JavaScript That is all! Any other technology you hear about is either: 1. a framework/library based on one or more of these client side technologies (e.g. jque...