/

HTML / CSS / JavaScript Tutorial

HTML Element: <base>

[this page | pdf | back links]

The HTML <base> element specifies the base URL for all relative URLs in a document. There can be at most one <base> element in any specific document (and it should be inside the relevant <head> element).

 

The attributes it can take (other than HTML global attributes and HTML event attributes) include:

 

Attribute

Description

More

href

URL of page the link goes to

Here

target

Specifies where / how to open the linked document (or where to submit the form)

Here

 

To create or access such an element in JavaScript see here. The corresponding HTML DOM object supports standard DOM properties and methods, and additional properties with the same name and meaning as the attributes of the underlying HTML element referred to above. It also typically supports the hash, host, hostname, origin, password, pathname, port, protocol, search and username variants of the href attribute, see here for more details. The default style applicable to this element is shown here.

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head id="headelement">
  <base href="Pictures/">
</head>
<body>
Created using HTML:<br>
Image is in Pictures directory but src attribute of image is just Shape1.jpg<br><br>
<img src="Shape1.jpg">

</body>
</html>


NAVIGATION LINKS
Contents | Prev | Next | HTML Elements


Desktop view | Switch to Mobile