Add to Google Feeds
HTML was the first markup language I learned, and its elegant simplicity provided a shallow learning curve that allowed users with even the most basic concept of computing to produce visually appealing websites. As multimedia content began to flood the Internet, HTML co-evolved with different server- and client- side scripting and programming languages to facilitate the new demands for interactive and dynamic content. The segregation of structural and visual attributes into XHTML and CSS represents a tremendous, but natural, leap forward in the language's evolution. XHTML allows authors to focus on a logical document structure with quality content by passing the majority of the difficult visual settings off the the Style Sheets. This logical division of labour may also explain why many scientists favour the LaTeX markup language over WYSIWYG word processors: writers can worry about their writing instead of wrestling with the typesetting. XHTML also provides HTML with XML compliance (hence the 'X'), the formal markup metalanguage that represents a degree of improvement over its SGML ancestor comparable to that offered by XHTML over its HTML predecessor. Many of the tags have been carried over from HTML, but with two important constraints introduced by the XML. The first is that all attribute valuesmust be enclosed in "quotation marks". Whereas <tr colspan=2> is a valid HTML tag, it must be <tr colspan="2"> to be a valid XHTML tag. The second constraint is that every opened tag must be closed. Even tags without natural closing counterparts (e.g. <br>) must be closed by including the closing in the tag (e.g. <br/>). Once you remember these two rules, then transitioning from HTML to XHTML is simply a matter of learning to separate content from appearance.
This article is a slowly evolving work in progress. It began with a simple list of text parameters, but I have been slowly adding other information to this document as I find the time. I have added information on document specifications and anchor tags. I am presently working on the table model. The syntax described here pertains to XHTML 1.1 and will also work with version 1.0 Strict1. Eventually, I imagine that it will serve as a slightly enhanced XHTML cheatsheet. I have elected to include only the more commonly used attributes, and have largely chosen to exclude even attributes in favour quicker access to information that is more likely to be of use.
An XHTML document opens with its type specification. An XML declaration may optionally be entered before the DOCTYPE specification. This is not required if the character encoding is the standard UTF-8, and this XML declaration may cause the browser to choke on your document. If used, however, the declaration looks like so:
<? version="1.0" encoding="UTF-8"?>
The XHTML document usually begins with the Document Type Declaration, which identifies the Document Type Definition (now you see why the former is called DOCTYPE and not DTD) to be used to check the validity of the document. The XHMTL DOCTYPE declaration tells the browser which DTD your document conforms to, and contains both a publicly recognized identifier and specific URL as a backup. The DOCTYPE declaration for XHTML 1.1 is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
Because an XHTML is an XML document, the namespace must also be identified. This is done after the DOCTYPE declaration with the line:
<html xmlns="http:www.w3.org/1999/xhtml">
This points to the XHTML namespace at W3.
As with traditional HTML, the remainder of the document is divided into the Header and the Body. With the exception of the tag closings, the elements in the header haven't changed much from their HTML counterparts.
| <base /> | Specify the base pathname for all relative URLs in the document. You can also use this tag to specify a default URL target. |
|
|
| <link /> | Define the relationship between the current document and another. Commonly used to define sylesheets. |
|
|
| <meta /> | Provide document metadata, including media, character set, author, description, etc. |
|
|
| <object /> | A generic element used to embed media objects. The attributes associated with this element vary with the type of object. See the W3 information on the XHTML Object Module for a detailed description of the syntax. |
| <script> | Place a script inside the document. Can also occur in the body. |
|
|
| <style> | Insert a stylesheet or style specifications |
|
† Required attribute
The body is where the document's content resides. An id attribute can be assigned to almost any element inside the body to allow the specification of presentational aspects in a Style Sheet.
| <br /> | Break the current line without breaking the paragraph. |
| <div id="idname"> | Introduce a generic division in the document. |
| <h1> | Top-level heading. Heading levels extend from 1 to 6. Headings 5 and 6 are usually smaller than the default text. |
| <hr /> | Insert a horizontal rule bar. Section borders are preferred. |
| <p> | Denotes a paragraph. |
Anchors and their role in hyperlinking could arguably be considered the backbone of the World Wide Web. They are what links documents (and parts thereof) together.
| <a> |
|
| Image Maps | |
|
|
| Examples | |
| Link local file (in same directory) | <a href="file.html">File</a> |
| Link file on another server | <a href="http://server.address/path/to/file.html">File</a> |
| Link to email address | <a href="mailto:usename@domain.type">Email User</a> |
| Link to FTP address | <a href="ftp://server.address/path/to/file">Download File</a> |
| Name an anchor | <a id="anchor">Anchor</a> |
| Link to named anchor in current document | <a href="#anchor">Go to Anchor</a> |
| Link to named anchor in external document | <a href="http://server.address/path/to/file.html#anchor">Go to Anchor</a> |
The following elements can be used to specify text structures. While a few presentational elements still remain, their use as such is discouraged.
| <abbr title="text"> | Identify the enclosed text as an abbreviation title -- the title of the abbreviation |
| <acronym title="text"> | Identify the enclosed text as an acronym title -- the title of the acronym |
| <address> | Identify the enclosed text as the authors contact information, but not an address listing. |
| <b> | Text will appear bold face2 |
| <bdo dir="ltr|rtl" lang="language code" xml:lang="text"> | "Bidirectional override" allows you to change the direction of the text. Either ltr or rtl must be specified The language can be specified using the lang= or xml:lang tag |
| <big> | Text will appear slightly larger than normal3 |
| <blockquote cite="URL"> | Enclosed text is a block quote (multiple paragraphs) |
| <caption> | A caption for a figure or table |
| <cite> | A reference to another document |
| <code> | A piece of code |
| <del title="text" cite="URL" datetime="YYYY-MM-DDThh:mm:ssTZD"> | Indicates deleted text title -- reason for deletion cite -- URL of a source document describing changes datetime -- Standard HTML timestamp |
| <dfn> | Indicates the defining instance of the enclosed term |
| <em> | Denotes text to be emphasized | <h1>...<h6> | Header designation, from level 1 to level 6 |
| <ins title="text" cite="URL" datetime="YYYY-MM-DDThh:mm:ssTZD"> | Indicates inserted text title -- reason for insertion cite -- URL of a source document describing changes datetime -- Standard HTML timestamp |
| <kbd> | Denotes text entered by the user ("keyboard") |
| <p> | Denotes a paragraph |
| <pre> | Denotes preformatted text |
| <q cite="URL"> | Denotes a brief (inline) quotation |
| <samp> | Denotes sample output from a program, script, etc. |
| <small> | Text will appear smaller than its surrounding text4 |
| <strong> | Denotes text to receive strong emphasis (e.g. bold) |
| <sub> | Indicates subscript text |
| <sup> | Indicates superscript text |
| <tt> | Denotes teletype text |
| <var> | Indicates a variable or program argument |
The combination of stylesheets and generic structures like <div> have largely usurped the role of the table as the weapon of choice for controlling the page layout. This is a good thing, as it frees tables up to do what they do best: present multidimensional information in an aesthetically pleasing and cognitively meaningful format. The relegation of the table back to its original purpose has reshaped its attribute set, and many generic display attributes have been deprecated in favour of ones that provide more structural control over the information content.
| <table> | Places a table within the document body. While the below attributes are valid, specifying these attributes with CSS is recommended. |
|
The information provided here is intended to serve largely as a quick reference. For more in-depth information, consult the resources listed below.
Comments
Post new comment