What is base tag and its function

Time:2020-10-16

The < base > tag specifies the default address or default destination for all links on the page.
Usually, the browser will extract the corresponding elements from the URL of the current document to fill in the blank space in the relative URL.
This can be changed by using the < base > tag. The browser will then no longer use the URL of the current document, but will use the specified base URL to resolve all relative URLs. This includes URLs in < a >, < img >, < link >, < form > tags.

Test:

1: The link path placed in front of the base tag can use a relative path and be relative to the current path,
However, the link placed after it uses the relative path, which will be the path specified relative to the base.
2: After using the base tag, the relative path of the link in the body will be the path specified relative to the base.
3: After using the base default target, the subsequent opening mode will be opened in the way specified by base, unless the opening mode is defined in the following display.
Conclusion: base is to define a default address and a default target. Any link elements that follow will work.