I connected the style.css file to header.php and everything works fine, but when I go to another page pages/test.php page, where the header.php file is style.css file style.css not work.

Here is a sample code:

header.php

 link rel="stylesheet" href="css/style.css" type="text/css"> 

test.php

 require_once '../header.php'; 
  • Open the JS console in your browser and look for errors - rjhdby
  • @rjhdby (not Found) - Cristian
  • If you open a page from pages/ , then your css/style.css turns into pages/css/style.css . Use absolute paths. - rjhdby

2 answers 2

Use the relative path from the site root.

 <link href="/css/style.css" media="all" rel="stylesheet" type="text/css" > 

    In the head you need to write:

     <base href='/'> 

    Such a problem will no longer be.

    • The problem will come out in another place where it will be necessary to connect scripts / styles from, for example, the current page directory - rjhdby