XHTML

The Extensible HyperText Markup Language (XHTML) is an application of XML in which a document is presented as a structure of nested elements. Along with content, an XHTML document provides its own logical structure without specifying how it should be rendered. Aspects such as font, size, and indentation are therefore determined by the application that interprets the document.

An XHTML document must be well formed, meaning that:

  • All elements must be explicitly closed, including empty elements such as img and br; for example, <img … /> and <br />.
  • All tag names are lowercase.
  • All attribute values are enclosed by either single or double quotes.
  • Attributes cannot be minimized. Thus, <option selected> is prohibited because the attribute selected contains no explicit value. Instead, use <option selected="selected">.

To build a Web application, you should have a good understanding of the structure of XHTML and its basic elements.

Structure

XHTML describes the logical structure of a document. The actual appearance of the document depends on the platform and browser with which it is being viewed and uses native fonts and colors.

XHTML code consists of elements which are marked up with tags:

<TagName {Attribute="Value" ...}>Text</TagName>

Any text not enclosed by tags appears as plain, left-aligned text in the browser’s default font.

The basic page layout of an XHTML page is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>A sample HTML page</title>
</head>
<body>...useful and inviting contents...</body>
</html>

Main Elements

The main elements of XHTML are:

  • <head>—contains information that is not displayed in the browser. The only visible element within the <head> is the <title> element that contains the text that appears in the browser title bar. The <head> element establishes relationships between this document and other resources. It can contain keywords for search engines, and meta data about the document, such as author or subject, and is the common location for scripting elements. It can also be downloaded separately, for example, by URL confirmation.
  • <body>—contains the contents to be displayed and formatted. This content is typically within other tags to provide basic text formatting such as headings, paragraphs, lists, and more advanced layout elements, such as tables or layers.
  • <form>—enables a static server page to submit data to the Web server so that Uniface can process user requests and create responses back to the browser. For information on how Uniface uses the form tag, see Layout of Static Server Pages.
  • <input>—associated with a field and widget for datta entry. The <body> and <form> elements contain <input> elements widgets for displaying and entering data. In static server pages these elements must be positioned within the <form> element if they are used to submit data. If they are located within the <body> element they can only be used to display data. In dynamic server pages, <input> elements use a different enable , widgets, such as text boxes, check boxes, lists, and so forth, that contain the data fields.

Hyperlinks—Absolute and Relative URLs

Hyperlinks are characteristic of the Web. They are point-and-click links to other places within the same document, or to another document or resource on the Web.

A hyperlink can reference a Web resource using its full Internet address or an address relative to the current document. An absolute URL gives all information necessary to locate the resource, including the protocol, and it has the syntax:

protocol://host/location/file

which means:

how://which machine/where/what

A relative URL is resolved by the browser based on the URL of the current document. If host is missing, the resource is requested from the same host as the current document. If the directory path is preceded by a forward slash (/), the search begins from the virtual root directory of the Web server. If the slash is omitted, the directory path is appended to the directory of the current resource. The directory path can also use dot notation to indicate relative directories, therefore ../ refers to the parent directory of the current directory.

When using hyperlinks within a site, use relative URLs wherever possible, because this makes the site more portable.