Home  >  Article  >  Web Front-end  >  How to use the `` tag to define the base URL of an HTML page?

How to use the `` tag to define the base URL of an HTML page?

WBOY
WBOYforward
2023-08-25 20:41:06819browse

How to use the `<base>` tag to define the base URL of an HTML page?

In this article, we will learn how to use the tag to define the base URL of an HTML page

In HTML, different elements have attributes that contain link to the other resources. The values ​​of these attributes are URL’s, these can be absolute or relative URL’s.

The HTML element specifies the base URL to use for all relative URLs in a document. There can only be one single element in a document, and it must be placed inside the

tag.

The following are the attributes of the HTML tag -

Both the href attribute and the target attribute, or both, must exist in the tag.

The Chinese translation of is:
S.No.S.No. Properties and Description
1

href

Base URL

2

Target

Where to open the target URL −

_blank - The target URL will open in a new window or tab.

_self - the target URL will open in the same frame as it was clicked.

_parent - The target URL will be opened in the parent frame

_top - The target URL will be opened in the top frame, i.e. the full body of the window.

grammar

<base herf= “base link…” target= “value”/>

Example 1

is translated as:

Example 1

The following is an example of using the tag in HTML to define a base URL -

<!DOCTYPE html>
<html>
<head>
   <meta charset="UTF-8">
   <meta name="description" content="meta tag in the web document">
   <meta name="keywords" content="HTML,CSS">
   <meta name="author" content="lokesh">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <!-- Declaring the BASE URL -->
   <base href="C:\Users\LOKESH BADAVATH\OneDrive\Desktop\TUTORIAL'S POINT\images\"target="_blank"/>
</head>
<body>
   <img  src="https://www.tutorialspoint.com/static/images/logo-color.png" / alt="How to use the `<base>` tag to define the base URL of an HTML page?" >
</body>
</html>
The Chinese translation of

Example 2

is:

Example 2

Another example of using the tag to define a base URL is as follows:

<!DOCTYPE html>
<html>
<head>
   <title>HTML base Tag</title>
   <base href = "http://www.tutorialspoint.com" />
</head>
<body>
   HTML: <br><img  src = "https://tutorialspoint.com/images/html.gif" / alt="How to use the `<base>` tag to define the base URL of an HTML page?" >
</body>
</html>

The above is the detailed content of How to use the `` tag to define the base URL of an HTML page?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete