TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

HTML base Tag

HTML base Tag with html tutorial, tags, anchor, img, div, entity, textarea, marquee, p tag, heading tag, h1, h2, table, formatting, attribute, elements, ol, ul, Input Types, block element tag, inline element tag, html tags, phrase tag, head, body, form, lists, symbols etc.

<< Back to HTML

HTML <base> tag

HTML <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.

Syntax

<base href="https://www.TheDeveloperBlog.com">

In HTML <base> element does not contain closing tag but in XHTML end tag </base> is required.

Following are some specifications about the <base> tag

Display None
Start tag/End tag Only start-tag
Usage Anchors and links

Example

Open in same window (by default)

<!DOCTYPE html>
<html>
<head>
	<title>Base tag</title>
	<style>
	  a{text-decoration: none;
		color:black;}
	  a:hover{color: green;
	               font-size: 18px;}
	</style>
	<base href="https://www.TheDeveloperBlog.com">
 </head>
 <body>
	    <h2 style="color: red; font-size: 30px; font-style: italic;">List of Web developement Tutorial</h2>
		<a href="/html-tutorial">HTML tutorial</a><br>
		<a href="/css-tutorial">CSS tutorial</a><br>
		<a href="/bootstrap-tutorial">Bootstrap tutorial</a><br>
		<a href="/javascript-tutorial">JavaScript tutorial</a><br>
	<a href="/jquery-tutorial">JavaScript tutorial</a>
  </body>
</html>
Test it Now

In the above example we have used base URL =" https://www.TheDeveloperBlog.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):

<!DOCTYPE html>
<html>
<head>
	<title>Base tag</title>
	<style>
	  a{text-decoration: none;
		color:black;}
	  a:hover{color: green;
			font-size: 18px;}
	</style>
	<base href="https://www.TheDeveloperBlog.com" target="_blank">
 </head>
 <body>
	    <h2 style="color: red; font-size: 30px; font-style: italic;">List of Web developement Tutorial</h2>
		<a href="/html-tutorial">HTML tutorial</a><br>
		<a href="/css-tutorial">CSS tutorial</a><br>
		<a href="/bootstrap-tutorial">Bootstrap tutorial</a><br>
		<a href="/javascript-tutorial">JavaScript tutorial</a><br>
		<a href="/jquery-tutorial">JavaScript tutorial</a>
  </body>
</html>
Test it Now

In the above example we have used target="_blank" in only <base> tag but it is applied on whole document links.

Attribute

Tag Specific attributes:

Attribute Value Definition
href URL It specifies the base URL for all relative links.
target
_blank Open the relative link in the new window
_self Open the relative link in current window
_parent Open the relative link in the parent frame
_top Open the links in full width of the page

Global Attribute

The <base> tag supports all global attributes in HTML

Event Attribute

The <base> does not support the event attributes in HTML

Supporting Browsers

Elementchrome browser Chromeie browser IEfirefox browser Firefoxopera browser Operasafari browser Safari
<base>YesYesYesYesYes
Next TopicHTML basefont Tag




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf