For the most part, HTML document tags are simple to understand and use since they are made up of common words, abbreviations, and notations. Every HTML tag consists of a tag name, sometimes followed by an optional list of tag attributes, all placed between opening and closing brackets (< and >). The simplest tags are nothing more than the tag name enclosed in brackets, such as <head> and <i>. More complicated tags have attributes, which may have specific values defined by the author to modify the behavior of a tag.
Tag attributes belong after the tag name, each separated by one or more tab, space, or return character. The order of attributes in a single tag is not important. An attribute's value, if it has one, follows an equal sign after the attribute name. If an attribute's value is a single word or number, you may simply add it after the equal sign. All other values should be enclosed in single or double quotation marks, especially if they contain several words separated by spaces. The length of an attribute's value is limited to 1024 characters. Here are some examples of tags with attributes:
<a href="http://www.ora.com/catalog.html"> <ul compact> <input name=filename size=24 maxlength=80> <link title="Table of Contents">
Tag and attribute names are not case-sensitive, but attribute values can be. For example, it is especially important to use the proper capitalization when referencing the URLs of other documents with the href attribute.
Most HTML tags consist of start and end tags that enclose text and other elements of a document. An end tag is the same as a start tag except it has a forward slash ( /) before the tag name. End tags never contain attributes. For example, to italicize text, you enclose it within the <i> tags:
<i>This text in italics.</i>
You should take care when nesting tagged elements in a document. You must end nested tags starting with the most recent one and work your way back out. In this example, a phrase in bold (<b>) appears in the text of a link (<a href=...>) contained in some body text:
<body> This is some text in the body, with a <a href="another_doc.html">link, a portion of which is <b>set in bold</b></a> </body>
There are a handful of HTML tags that do not have end tags because they are standalone elements. For example, the image tag (<img>) inserts a single graphic into a document and does not require an end tag. Other standalone tags include the linebreak (<br>), horizontal rule (<hr>), and tags that provide information about a document that doesn't affect its displayed content such as the <meta> and <base> tags.
In some cases, end tags can be omitted in a document. Browsers often assume the end of one element when another begins. The most common example of this is with the paragraph tag (<p>). Since it is so often used in a document, a <p> tag usually only appears at the beginning of each paragraph. When one paragraph ends, another <p> tag signals the browser to end the paragraph and start another. Most authors do not use an end paragraph tag. There are other end tags that browsers function fine without, such as an ending </html> tag. However, it is best to include the end tags as much as possible to avoid confusion and mistakes in displaying your document.
|HTML Document Structure||Book Index||HTML Tags|