Header elements

The following elements are used in the header section of an XHTML document. To these elements can be added the Object element, which is also used in the body of a document, and is described later.

Meta tags

The empty Meta element is of most interest to those involved in browser/server communication. The Name attribute provides the name of the meta-information (almost an attribute name in itself), and the Content attribute provides the current value for the named item. For example:

<meta name="Index"  content="cycle" />

This could be considered equivalent to an XML attribute such as 'Index="cycle"'. If more than one Meta element is present with the same Name attribute value, the various content values are accumulated into a comma-separated list, for example 'cycle, bus, car'.

The third attribute, HTTP-Equiv, allows the content to be inserted into an HTTP header field.

The Scheme attribute may be used to indicate what standard scheme the value adheres to. For example, the scheme might be 'isbn' if the value is an ISBN (an International Standard Book Number).

Linked resources

The Link element identifies other resources that are connected to this document, such as a stylesheet. To identify the resource, it has an Href attribute, and a Type attribute to identify the language used. The Title attribute holds a brief description of the resource:

<link title="big print" href="bigprint.css"
      type="text/css" />

Note that this usage is equivalent to the xml-stylesheet processing instruction, and should only be used for backward compatibility with HTML. A number of attribute may be present. The Media attribute is used when the link is to a stylesheet, and has values such as 'screen' and 'print' that specify when the stylesheet should be applied. The Href Language (Hreflang) attribute holds a language code conforming to the RFC 1766 specification (see the ISO 639 language codes table in Chapter 33). The Charset attribute explains which character set the document conforms to, as defined in RFC 2045.

Styles

The Style element encloses stylesheet instructions. The required Type attribute identifies the stylesheet language, such as 'text/css' or 'text/xsl'. The Media attribute identifies the type of media the stylesheet is aimed at, such as 'screen' (the default) or 'paper'. A Title attribute is also allowed to identify the stylesheet:

<style type="text/css" media="screen">
  p { color: green }
</style>

The XML Space attribute is also used, and fixed in the DTD to the value 'preserve', to prevent the stylesheet instructions from being reformatted (and possibly merged).

Scripts

The Script element is used to enclose or reference software scripts. A CDATA section is often required to allow significant characters such as '<' and '&' to appear in the script without escaping them.

The required Type attribute describes the scripting language used, such as 'text/javascript'. The Src attribute identifies a remote file containing the scripts, using a URL. When Src is used, the Charset attribute may also be used to identify the character set used in the file that contains the scripts. The Defer attribute takes a single possible value of 'defer' to indicate, when present, that the browser should defer executing the script (this is a hint that the script does not alter the document in any way, so the browser can go ahead and render the document). The XML Space attribute is also used, and fixed in the DTD to the value 'preserve', to prevent the scripts from being reformatted.

The NoScript element has been included to hold alternative information in case the browser is configured to prevent scripts from running or is not familiar with the scripting language used. Despite appearing in the header section of the document, it holds the block-level body elements described below to format the content.

Base URL locations

When relative paths are included in the URL, the starting point is normally the address of the page containing the link. The optional Base element is used to provide a new fixed point in the directory structure from which relative links should be calculated. It uses an Href attribute to specify the replacement path. Note that this element provides the same functionality as the new XML Base standard (see Chapter 11).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.132.194