开发者

HTML: anchor attribute when pointing to index file

开发者 https://www.devze.com 2023-02-27 11:21 出处:网络
Considering leaving the href attribute empty for anchor tags开发者_StackOverflow is not a best-practice, how do I go about doing that \"legally\"?

Considering leaving the href attribute empty for anchor tags开发者_StackOverflow is not a best-practice, how do I go about doing that "legally"?

I don't want to link to index.html or index.php or such, I want to link to the default index file in that document.

Setting it to / does the trick if you are in the root, otherwise it will still go there so it's not a solution.

How should I do this?

Thank you.


If you wish to link to the default document at your current directory, this should be valid:

<a href="./">My Directory's Default Document</a>

If you just wish to have an anchor tag that does not leave the current page:

<a href="#">Go Nowhere</a>


Try linking to ./ - think that should do it


Consider doing it server side.

You can create a function in PHP (causes that's what you are using, right) that would take the current URL and add the current directory and render that.

Do include the domain as they say it is good for SEO.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号