javascript – Linking resources, such as CSS, within a site's structure


I'm a beginner and I'm having problems with linking scripts, CSS and images. I have the following folder structure on my site, just an example:

- Pasta Raiz    
    --- cadastro.html
    --- icon.png  
    --- script.js  
    --- cabecalho.css

Assuming all the pages on my site have the same header, then I would have to import all of them CSS cabeçalho.css . For the home page it's easy.

But to call this same css on the cadastro.html page? In my point of view, for cadastro.html the style cabecalho.css doesn't exist, I wanted to know how to link them, because it's a complete disorganization to leave all your pages in the root folder.


One way would be to use the base tag to set the default url

<base href="http://meu-dominio/">
<link type="text/css" href="style/cabecalho.css">

This way the path will be the same both on the index.html page and on the cadastro.html page

<link type="text/css" href="http://meu-dominio/style/cabecalho.css">
Scroll to Top