HTML <base> tagHTML <base> tag is used to specify a base URI or URL to use for all relative links contained within an HTML document. Only one <base> element can be specified within a document, and it must be placed within <head> element. We can also specify how other links should open (in the same window, in another window, etc.) using the target attribute. SyntaxIn HTML <base> element does not contain closing tag but in XHTML end tag </base> is required. Following are some specifications about the <base> tag
ExampleOpen in same window (by default) Test it NowIn the above example we have used base URL =" https://www.javatpoint.com" which all other relative links will treat as starting URL. Here (/) defines the root URL of the current document. Open in new window (using _blank in <base> tag):Test it NowIn the above example we have used target="_blank" in only <base> tag but it is applied on whole document links. AttributeTag Specific attributes:
Global AttributeThe <base> tag supports all global attributes in HTML Event AttributeThe <base> does not support the event attributes in HTML Supporting Browsers
Next TopicHTML basefont Tag
|