HTML base Tag href Attribute Tutorial

In this section, we will learn about HTML <base> href attribute.

What is href Attribute in HTML <base> Tag?

HTML href attribute is used to set the base URL for HTML <base> element. Browsers then use this base URL to create the absolute URL for all relative links on the page where <base> element is used.

HTML href Attribute in <base> Tag Syntax:

<base href = "base-url">

<base> Tag href Attribute Values

The value of href attribute is the base URL for all relative addresses on the page.

Example: using href attribute in HTML <base> tag

See the Pen using href attribute in HTML <base> tag by Omid Dehghan (@odchan1) on CodePen.

In this example, the base URL is “https://www.google.com” and so browsers use this base address to create the absolute URL for relative addresses like “/imghp” in this example.

So at the end, the absolute address for “/imghp” becomes : https://www.google.com/imghp

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies