Showing posts with label head tag. Show all posts
Showing posts with label head tag. Show all posts

Wednesday, January 5, 2011

The head Element

The head element contains information that describes the (X)HTML document. This information is not considered part of the content of an (X)HTML page and is therefore not displayed in the viewport.

The head element must contain one title element.

These are the elements that head can contain:

  • title
  • base
  • meta
  • script
  • link
  • style
  • object

There can be only one title and base element. However, the other elements can be present multiple times.

Attributes

lang and xml:lang
These attributes specifiy the language of the contents of the head element. However, this attribute is more often specified for the html element. See this page for more information.
dir
See this page.
id
This attribute is used to uniquely name the head element. It is allowed on the head element only when the doctype is XHTML.
profile
The value of this attribute is the URI of a document that provides more information of the meta element's content attribute.

Here is the W3.org's HTML 4 specification page for the head element.

Friday, August 15, 2008

External Style Sheets - <link>, <style> and @import

An external style sheet is a text file containing CSS rules - it does not contain any HTML. It has the file extension .css.
There are two ways of linking an external style sheet - using the <link> element and the other way is using the <style> element and the @import directive.

The link tag

Example:
<link rel="stylesheet" type="text/css" href="styles/sheet1.css" media="all" />
The above code is used to link a style sheet called sheet1.css to the current HTML document using the href attribute. This attribute's value is a URL of the style sheet file. Also, the style sheet applies to any media that the document is being viewed in (the media="all" attribute-value pair). The two other attribute-value pairs (rel="stylesheet" and type="text/css") must be included. You can also include the title attribute. Firefox displays the name of the style sheet in the View > Page Style menu, Opera in the View > Style menu. If you have more than one stylesheet with a title attribute, Firefox and Opera allow the user to choose which one should be applied by selecting it from the View menu.

The <style> tag and the @import directive

The <style type="text/css"> element contains CSS rules. The @import directive is a CSS statement that loads an external style sheet. This directive must be placed before any other CSS rules. The media to which the style sheet must be applied can be specified as a comma separated list.
Example: <style type="text/css">
@import url(styles/sheet1.css) screen, print;
p {font:62.5%}
</style>

Monday, August 11, 2008

The <link> element

The link element is contained in the head element. The purpose of this element is to define the relationship between the current document and another document. link is an empty element.
With the link tag, you can specify the relationships between the documents of a document set.
The href attribute's value is the URL of the target. This is a required attribute. The rel attribute specifies the relationship from the current document to the target document. The rev attribute specifies the reverse: the relationship from the target document to the current document.
The relationship can be specified by the values next or prev indicating next or previous.
The title attribute specifies the name of the target document.
The type attribute specifies the MIME type of the target document.
Example: <link rel="stylesheet" href="alltags.css" type="text/css" />
Browsers do not do anything with the link tag. However, this tag can be used by you to organize a web site. It can also be useful when using server-side scripting to generate pages.

Tuesday, August 5, 2008

The <title> tag

This is an element that is compulsory in XHTML documents. It is a contained in the head element.
The text inside the title element is considered the title of the document. It is displayed in the title bar of the browser. This element can contain only text.
Example: <title>The Page Name</title>