Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css file path is right, css code is valid, but it doesn't work

I have a weird, annoying problem. I have a css/ folder and index.html at the root. I load css files in the header as follows:

<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title>blabla</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="keywords" content="keywords" />
    <meta name="description" content="desc" />

    <!-- style files -->
    <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/global.css" media="screen" />
</head>

but the css is not working: I see a plain index.html. I'm sure the css path is right; when I click "view source" and copy/paste the css files path, it shows the css files.

Also, when I copy the css directly into index.html, it works. What could be the problem?

like image 793
designer-trying-coding Avatar asked Dec 30 '22 09:12

designer-trying-coding


2 Answers

Probably not served as text/css. Did you check your server config?

like image 112
jensgram Avatar answered Apr 07 '23 21:04

jensgram


The relative URL is likely wrong. To help you further we need to know two things:

  1. What is the full (absolute) URL with which you open the HTML page? Check browser address bar.
  2. What is the full (absolute) URL with which you can open the CSS file individually in your browser?

Once you know both, you can do the math to get the right relative path for use in link tag.

like image 34
BalusC Avatar answered Apr 07 '23 21:04

BalusC