I'm ashamed that I need to ask this question. I've been using PHP for
almost a year now, and have used HTML extensively in the last few
years.
Often, when I create a new site, I use include() to add an HTML header
at the top of the page and a footer (ususally including a menu) at the
bottom.
Up to now I've created two or more copies of each header and footer,
the only difference being the path to linked files. For example, in
the root directory I need to reference a stylesheet as
'style/screen.css', but in files within another directory I use
'../style/screen.css' or '../../style/screen.css'.
Now this is the part I'm ashamed about! I realised today that I could
just use '/style/screen.css' within the file in the root directory and
any other directory you care to mention. I've no idea how I missed
this and I'm sure I've never seen it in anyone else's HTML or in any
turtorials.
Can someone please confirm that it's ok to do this (i.e. one header
file and one footer file, using '/dir/file' as the link rather than
'dir/file' or '../dir/file')?
I hope this makes sense and that you can forgive my stupidity?
Jez
almost a year now, and have used HTML extensively in the last few
years.
Often, when I create a new site, I use include() to add an HTML header
at the top of the page and a footer (ususally including a menu) at the
bottom.
Up to now I've created two or more copies of each header and footer,
the only difference being the path to linked files. For example, in
the root directory I need to reference a stylesheet as
'style/screen.css', but in files within another directory I use
'../style/screen.css' or '../../style/screen.css'.
Now this is the part I'm ashamed about! I realised today that I could
just use '/style/screen.css' within the file in the root directory and
any other directory you care to mention. I've no idea how I missed
this and I'm sure I've never seen it in anyone else's HTML or in any
turtorials.
Can someone please confirm that it's ok to do this (i.e. one header
file and one footer file, using '/dir/file' as the link rather than
'dir/file' or '../dir/file')?
I hope this makes sense and that you can forgive my stupidity?
Jez
Comment