HTML <base> Tags
1. The definition:<base> tag is the base URL tag in the HTML language and is a single label.
2. Function: Specify the default URL and default target for all links on the page.
For example:
<!DOCTYPE HTML><HTMLLang= "en"><Head> <title>Base</title> <MetaCharSet= "UTF-8"> <Basehref= "http://www.w3cschool.cn"Target= "_blank"></Head><Body><P>The absolute path to SRC in the img tag is http://www.w3cschool.cn/statics/images/course/planets.gif</P><imgsrc= "/statics/images/course/planets.gif"width= "145"Height= "126"alt= "Planets"></Body></HTML>
Note: Base rules are the default URLs for all links on the pageand are all! It includes all URLs such as Src,href.
The links used will be spliced with the href link in base.
Example of a CSS file cannot be found:
<!DOCTYPE HTML><HTMLLang= "en"><Head><title>Base</title> <MetaCharSet= "UTF-8"><Basehref= "http://www.w3cschool.cn"Target= "_blank"> <Linkrel= "stylesheet"type= "Text/css"href= "Css/first.css" > <!--Link External Resources -</Head><Body><p> External style sheet to reference a file in a non-base linked directory, the stylesheet will not be found. </p></Body></HTML>
Nutshell:
The base tag has the following rules
- The <base> tag must be inside the
- You can use a maximum of one <base> tag in a document.
- After using the <base> tag link, the other links must be in the <base> tag link, otherwise it will not be found.
Correct use of <base> tags in html