Xodarap
Xodarap

Reputation: 11859

How can I relatively link to a sub folder in HTML?

On page /foo I would like to link to /foo/bar. <a href="./foo/bar"> works, except that it requires me to know that I'm currently on /foo.

Is there a way that I can just append a suffix without needing to know the current path?

Upvotes: 1

Views: 262

Answers (1)

step
step

Reputation: 2409

At "html" "head" you can define base path and all other hrefs can be relative to this base. Some examples of "base" tag:

<base href="https://www.example.com/">
<base target="_blank"> 
<base target="_top" href="https://example.com/">

Upvotes: 1

Related Questions