Correct use of <base> tags in html

Source: Internet
Author: User

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

    1. The <base> tag must be inside the
    2. You can use a maximum of one <base> tag in a document.
    3. 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

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.