(006) The head of the XHTML document

Source: Internet
Author: User

First, Introduction

This section describes the head element, which contains information about the document. Although the head element and its contents are not displayed by the browser, they play a key role in defining some special aspects of the document, including JavaScript code, the name of the document, and the style declaration of the document.

Many people see head as a section and as an element. As an element, it can contain several other elements, all of which are the objects of interest in this chapter. One of the interesting things about the head element is that it does not include any elements that will appear in the document. The elements that can be included in the head element are base, link, Meta, script, style, title.

Second, the base element

The base tag helps to make the links shorter and easier to maintain. It can be used to specify a base URL for all links in the document.

The base tag has only one required property,--href. It is used to specify a URL to use as the underlying URL for a link in a document.

For example, when you add an image to an XHTML document, you need to indicate where you can find the image. Using <base> tags can make things easier when multiple images are in the same directory. That is, if the document contains several images from the same directory, you can make their URLs shorter by using the <base> tag. In addition, when you decide to move these images to a new location, modifying those links is just a trivial matter, just modify the <base> tag's href attribute on the line.

When the browser is ready to get the image, it takes out the base URL specified in the <base> tag and combines it with the requested file. When multiple images are present, using the <base> tag is an efficient means because it saves typing time and reduces the overall size of the file.

Usage:

<base href= "..."/>

  

Third, LINK element

The link element defines a relationship between two documents linked together. It is most commonly used to link an external style sheet into the current document.

The properties of the link element are described below:

    • href: The URL to the linked document
    • Media: Describes which media the linked document is for. Common values include all, Braille, print, projection, screen, and speech. With the media property, you can specify different style sheets for different media types. For example, you might want to make the content on your screen look colorful, but some users may only have a monochrome printer. This property allows you to use a different style sheet for each media type.
    • Rel: Defines the relationship between the document that is linked to and the current document. Common values include alternate, appendix, bookmark, chapter, contents, Copyright, glossary, Help, Home, index, Next, prev, section, Start, Stylesheet, subsection.
    • Rev: In contrast to rel, this attribute defines the relationship between the current document and the linked document.
    • Type: Specifies the Multipurpose Internet Mail Extension (MIME) type of the destination URL. The most common values include text/css for external style sheets, text/javascript for JavaScript files, and image/gif for GIF image files. The MIME type tells the browser what type of file is being downloaded and how it should be handled.

Use the following:

  

The head of the

(006) XHTML document

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.