[HTML] Absolute href vs relative href
An absolute URL - points to another web site (like href="http://www.example.com/default.htm")
A relative URL - points to a file within a web site (like href="default.htm")
When you have a <a href="./a/1.html">W3Schools</a>
-- this is a relative URL, assume we are currently on this page: https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_a_href
you can open devtool seeing that:
Browser will convert a href
to a absolute url for sure.
Rules:
Relative path:
Given: https://www.example.com/a/b/c/1.html
href: ./2.html
Result: https://www.example.com/a/b/c/2.html
Given: https://www.example.com/a/b/c/1.html
href: ../2.html
Result: https://www.example.com/a/b/2.html
Given: https://www.example.com/a/b/c/1.html
href: ../../d/2.html
Result: https://www.example.com/a/d/2.html
Absolute path:
Given: https://www.example.com/a/b/c/1.html
href: /js/app-zwan123.js
Result: https://www.example.com/js/app-zwan123.js
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2024-02-06 [Go] Unit testing Go code
2024-02-06 [Go] Go routines with WaitGroup and async call
2024-02-06 [ Go] GoRoutines and Channels
2024-02-06 [Go - slice] Remove Elements from a slice in Go
2024-02-06 [Go] defer & recover
2024-02-06 [Go] Defer keyword
2023-02-06 [Typescript] Global Scope