1

On my .php file I just started to write the website. So I started by linking the .css files. But they don't work. I plan to use php in this file so I use the PHP exetension and run it with the latest version of XAMPP

By taking a look in the network tab, I see that the .css files are there with status 200.

body {
   color: red;
}
<!DOCTYPE html>
<html lang="en">

<head>
    <link rel="stylesheet" href="css/styles.css">
    <link rel="stylesheet" href="css/index.css">
</head>

<body>
    <h1 class="mainheader">Kraut und Rueben</h1>
</body>

</html>
Full code here: https://github.com/AlexBrightwater/Kraut_und_Rueben/tree/main/frontend Using JS fiddle, I can confirm that the code theoretically works. https://jsfiddle.net/1vfn6Ly0/

I saw posts here from some years ago but their solutions didn't work:

Alexander
  • 13
  • 5
  • 1
    If the files are being loaded with a 200 this implies they are being applied successfully. If they aren't adjusting the appearance of your HTML in the way you'd expected then that needs fixing separately - we would need to see examples of the CSS you're trying to apply, and the HTML you're trying to apply it to, and what changes you were expecting to see from the application of those rules. In other words, please provide us a [mre] of your issue. See also [ask] for more guidance. Thanks. – ADyson Sep 30 '21 at 11:24
  • P.S. Something you could do to verify more easily if it's your environment which is at fault, or the combination of HTML and CSS not working together, is to run the code in another environment. With HTML/CSS this is quite easy - you can just paste the code into a site like JSFiddle or CodePen and run it there, and see what result you get. There's even a "code snippet" feature within Stackoverflow which can be used for this purpose too (you can find it when you edit your question). – ADyson Sep 30 '21 at 11:26
  • 1
    What have you tried to resolve the problem? Where are you stuck? How is this related to PHP? – Nico Haase Sep 30 '21 at 11:26
  • Added code to example @ADyson – Alexander Sep 30 '21 at 11:35
  • Thanks. I made it into a runnable snippet as you can see (you don't need the JSFiddle now). So as you've seen yourself, the CSS is trivial and works ok. If you're not seeing it working in your local environment, but yet the CSS files are returning 200 OK when loaded into the page, then it's a bit mystifying. When you are looking at the network tab for those CSS files, can you look in the raw Response tab for each of the files and confirm whether they actually contain the CSS you're expecting them to (and no other stuff which might make it invalid)? – ADyson Sep 30 '21 at 11:45

0 Answers0