微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用`<base>`标签来定义HTML页面的基本URL?

如何使用`<base>`标签来定义HTML页面的基本URL?

在本文中,我们将学习如何使用<base>标签来定义HTML页面的基本URL

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 <base> HTML element specifies the base URL to use for all relative URLs in a document. There can only be one single <base> element in a document, and it must be placed inside the <head> tag.

以下是HTML 标签属性 -

必须在<base>标签同时存在href属性和target属性,或者两者都有。

中文翻译为:
S.No.S.No. 属性和描述
1

href

基本URL

2

目标

在哪里打开目标URL −

_blank - 目标URL将在新窗口或选项卡中打开。

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

_parent - 目标URL将在父级框架中打开

_top - 目标URL将在顶部框架中打开,即窗口的完整主体。

语法

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

Example 1

的翻译为:

示例1

以下是使用HTML中的<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" />
</body>
</html>

Example 2

中文翻译为:

示例2

使用标签定义基本URL的另一个示例如下:

<!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" />
</body>
</html>

以上就是如何使用`<base>`标签来定义HTML页面的基本URL?的详细内容,更多请关注编程之家其它相关文章

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐