How to get to the root?

S

Samuël van Laere

Hi friendly people (yeah even you Brucie beast),

I've just got a stupid question and it probally got an easy answer
i'm sure I once knew how to do it, but I forgot, so here goes:

root/style.css
root/mydirectory/page1.html

How can I include the style.css file into page1.html without using a
absolute url?

I'll try to remember it this time. :p

With regards,
Samuël van Laere
the Netherlands
 
N

Neal

Hi friendly people (yeah even you Brucie beast),

I've just got a stupid question and it probally got an easy answer
i'm sure I once knew how to do it, but I forgot, so here goes:

root/style.css
root/mydirectory/page1.html

How can I include the style.css file into page1.html without using a
absolute url?

I'll try to remember it this time. :p

To refer to the root, start with / then indicate the path.

In your case, you could use /style.css (static) or ../style.css (relative).
 
S

Sam Hughes

Hi friendly people (yeah even you Brucie beast),

I've just got a stupid question and it probally got an easy answer
i'm sure I once knew how to do it, but I forgot, so here goes:

root/style.css
root/mydirectory/page1.html

How can I include the style.css file into page1.html without using a
absolute url?

I'll try to remember it this time. :p

.../style.css
 
B

brucie

In alt.html Samuël van Laere said:
Hi friendly people (yeah even you Brucie beast),

i really am a nice guy, people just use a nasty font in their
newsreaders that makes me sound evil. try a nice VladimirScrD and you'll
be pleasantly surprised.
 
N

Neal


What's wrong with the above? I don't see it. Please point it out, and tell
me what would be correct.

It exactly parallels the line

<LINK rel="stylesheet" href="bach.css" type="text/css">

found at http://www.w3.org/TR/CSS21/intro.html . Except the ../ is used to
point the browser up a directory relative to the current one, which is
what OP wanted.
 
K

Karl Core

Neal said:
What's wrong with the above? I don't see it. Please point it out, and tell
me what would be correct.

It exactly parallels the line

<LINK rel="stylesheet" href="bach.css" type="text/css">

found at http://www.w3.org/TR/CSS21/intro.html . Except the ../ is used to
point the browser up a directory relative to the current one, which is
what OP wanted.

That does not necessarily lead to root. If the page in question is three
directories deep and the style sheet is in the doc root, then it doesn't go
deep enough.
The answer would be <link rel="stylesheet" href="/style.css"
type="text/css">


-Karl
 
N

Neal

Karl said:
That does not necessarily lead to root. If the page in question is three
directories deep and the style sheet is in the doc root, then it doesn't
go deep enough.

Yes, I agree. But the poster gave an example of the directory structure
where the page was in the very next level (snipped in Marcus' reply).

root/style.css
root/mydirectory/page1.html

For the OP's situation, it should work fine. Though it is also true that
if the page were moved to a different directory level, unless the css file
was moved similarly the relationship would break.
 
K

Karl Core

Neal said:
Yes, I agree. But the poster gave an example of the directory structure
where the page was in the very next level (snipped in Marcus' reply).

root/style.css
root/mydirectory/page1.html

For the OP's situation, it should work fine. Though it is also true that
if the page were moved to a different directory level, unless the css file
was moved similarly the relationship would break.

My apologies, Neal. I didn't see the OP, just Marcus' reply.

-Karl
 
T

Toby Inkster

Karl said:
<link rel="stylesheet" href="/style.css" type="text/css">

But the OP said:

| How can I include the style.css file into page1.html without using a
| absolute url?

"/style.css" is absolute (though I believe it is what the OP wants deep
down).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top