An Interest In:
Web News this Week
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
- April 12, 2024
May 27, 2021 07:11 am GMT
Original Link: https://dev.to/rajeshkumaryadavdotcom/html-specify-a-default-url-and-a-default-target-for-all-links-on-a-page-3b26
HTML : Specify a default URL and a default target for all links on a page
The HTML <base>
element specifies the base URL to use for all relative URLs in a document. There can be only one <base>
element in a document.
Full information at https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
Routing or URL rewriting with base tag
Let's say you are located at:
www.domain.com/folder/subfolder/
Now if in your index.html file, you have the anchor tag to redirect to test.html as -
<a href="test.html">Click here</a>
Then this anchor will be regular anchor and will leads to
www.domain.com/folder/subfolder/test.html
Now if you will add base
tag in your index.html's head
tag as -
<base href="http://www.domain.com/" />
Then your same anchor
<a href="test.html">Click here</a>
now will lead to
www.domain.com/test.html
With all that being said, I highly recommend you keep learning!
Thank you for reading this article. Please feel free to connect with me on LinkedIn and Twitter.
Original Link: https://dev.to/rajeshkumaryadavdotcom/html-specify-a-default-url-and-a-default-target-for-all-links-on-a-page-3b26
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To