HTML tag
An HTML tag is part of the World Wide Web markup language HTML, denoting the start and end of an element, and, through its attribute values, sets properties of that element.For instance, the <em> tag begins an EM element (used for marking emphasized text). (The user agent may choose how to indicate this emphasis.) Where an element is not empty (such as a line break or horizontal rule), an opening tag should be matched with a corresponding "end" tag, which is identical to the opening tag except that it begins with a slash (i.e. </em> for the emphasis tag).
| Table of contents |
|
2 The document type definition (DTD) 3 External link |
Syntax
Note that HTML, but not XHTML, through some SGML features ("SHORTTAG") allows various abbreviated notations, which make the following equivalent:<element-name attribute-name="attribute-value">content</element-name>
<ul>
<li>Foo</li>
<li>Foo</>
<li>Foo
<li/Foo/
<>Foo
</ul>Furthermore the trailing angle bracket can be omitted when another opening one directly follows (<code><li<em>Foo</em</li></code).
If an attribute can only take predefined values, the attribute name itself and the equals sign can be omitted (<p left>); when the only valid value is called the same as the attribute, you get "binary attributes" (<dl compact> = <dl compact="compact">).
Web browser support for these features is very limited, though, and this may or may not work at all in your web browser. Do not rely on this behaviour, instead always write full tags and attributes, and quote any attribute values.
Whenever an attribute requires you to specify a color (such as a text or background color), there are two ways to do this. The more flexible of these is hexadecimal RGB notation. A hexadecimal RGB color consists of six hexadecimal digits. The first pair of these signifies the brightness of the red-light component of the color; the second pair, the blue-light component; the third, the green-light component. By combining different values, 16 million colors can be defined.
There are 2 types of tags:
- Container Tags - must have a closing tag
- Stand-Alone Tags - does not have a closing tag
- ... - opens the HTML code
-
... - gives the text to be displayed in Title Bar - ... - holds the actual content in the HTML page
- ... - tag to hold a hyperlink
- - used to insert programs into the document such as JavaScript or VBScript
- - used to create forms for user interaction
All HTML documents must start with the Document Type Definition or DTD. This is one of the following:
The document type definition (DTD)
"http://www.w3.org/TR/html4/strict.dtd">
Use for documents which completely follow the standard. This triggers standards-compliant rendering in modern web browsers. "http://www.w3.org/TR/html4/loose.dtd">
Use if you use deprecated tags (such as <B>). This typically triggers a bugwards-compatible rendering mode in modern web browsers, which breaks some parts of the standard. "http://www.w3.org/TR/html4/frameset.dtd">
Use only if your page is a frameset.