What does the HTML base tag do? Analysis of the function of the base tag (with example)

Source: Internet
Author: User
This article mainly introduces the usage of the HTML base tag, as well as the analysis of the role of the HTML base tag, let's take a look at this article.

First, let's analyze the role of the HTML base tag:

The base tag is the base URL tag in the HTML language, which is a single label, located within the head tag of the header file of the Web page, where a page can use a maximum of one base element to provide a specified default target, as well as a token for the expression path and connection URL.

Common URL path forms have relative paths and absolute paths, and if the base tag specifies a target, the browser will resolve all the relative paths in the current document, including the tags (A, IMG, link, form), i.e., The browser parses the path with the base-given target, and the relative path in the page is converted to an absolute path. The base tag should be used with the HREF attribute and the target property.

Talk about the base href attribute:

For example, the base has a URL address, and then the file or image you want to call no longer fill in the full address, just write the file name or picture name. Get a simple look at the usage of the base tag using one of the images below, link to Topic.alibabacloud.com's HTML video tutorial, full address http://www.php.cn/course/list/11.html

The base tag specifies the topic.alibabacloud.comhtml video tutorial as the base URL, then all hyperlinks in the current document will follow this rule, we set the relative access target in the link, the browser will automatically parse out a complete link address to access, if the target of a link is empty, browse will also be accessed based on the URL given by base. It is important to note that the base tag needs to be placed in front of the statement that contains the URL address.

Again, the base target property:

The target property is the way the page window is opened and the property is set in the Base tab, so all links in the page follow this way to open the page, with the following options:

    • _blank: Opens the link page in a new window.

    • _parent: Opens the link in the previous level window.

    • _self: Opens the link in the current window, this is the default value, can be omitted.

    • _top: Opens the link in the browser's entire window, ignoring any frames.

The function analysis of HTML base tag:

This is the basic HTML language. Use <base target=_xx> to set the target window for all links on this page. That is, as long as you add <base target=_xx> to the page, all hyperlinks need not be set separately. It is better to write this sentence between

The meaning of the HTML base tag in the JSP:

The base tag is a base link tag and is a single tag. The default value of the parameter used to change all the link tags in the file. It can only be applied between tags

All relative paths on your Web page will be preceded by the address that the base link points to.

JSP page can be defined as: <% String basepath = request.getscheme () + "://" +request.getservername () + ":" +request.getserverport () + path+ "/";%>

After the head tag, add <base href= "<%=basePath%>" >.

The above is about the role of the HTML base tag introduction (Want to learn more HTML knowledge, to Topic.alibabacloud.comHTML video tutorial), there are questions can be in the bottom of the message to ask questions. Here is also a description of the use of HTML base tags: how to use theHTML base tag? Summary of usage of HTML base tags

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.