Question:
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
--- cadastro.html
--images
--- icon.png
--script
--- script.js
--style
--- cabecalho.css
index.html
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.
Answer:
One way would be to use the base tag to set the default url
<head>
<base href="http://meu-dominio/">
<link type="text/css" href="style/cabecalho.css">
</head>
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">