![]() |
|||||||||||||
|
HTML element |
In computing, an HTML element indicates structure in an HTML document and a way of hierarchically arranging content. More specifically, an HTML element is an SGML element that meets the requirements of one or more of the HTML Document Type Definitions (DTDs). These elements have properties: both attributes and content, as specified (both allowable and required) according to the appropriate HTML DTD (for example, the HTML 4.01 strict DTD). Elements may represent headings, paragraphs, hypertext links, lists, embedded media, and a variety of other structures.
Syntactically HTML elements are constructed with:
Many HTML elements include attributes in their start tags, defining desired behavior or indicating additional element properties. The end tag is optional for many elements; in a minimal case, an empty element has no content and requires no end tag. There are a few elements that are not part of any official DTDs, yet are supported by some browsers and used by some web pages. Such elements may be ignored or displayed improperly on browsers not supporting them.
Informally, HTML elements are sometimes referred to as "tags" (an example of synecdoche), though many prefer the term tag strictly in reference to the semantic structures delimiting the start and end of an element.
XHTML is the successor to HTML 4.01; XHTML 1.0 supports the same elements as HTML 4 and in most cases valid XHTML 1.0 documents will be valid or nearly valid HTML 4 documents. XHTML 1.0 migrates HTML from its SGML underpinnings to an XML foundation. Accordingly, the discussion of elements within this article focuses on the final SGML based HTML, version 4.01 (unless noted otherwise). However, to the extent that XHTML 1.0 elements remain identical to the HTML 4.01 elements, the discussion remains applicable (see HTML for a discussion of the minor differences in content between XHTML 1.0 and HTML 4.01).
| HTML |
|---|
Contents |
<title>…</title>
title element must not contain any nested tags (that is, it cannot contain any other elements). Only one title element is permitted in a document.<base>
href and other links in the document. Must appear before any element that refers to an external resource. HTML permits only one base element for each document. The base element has attributes, but no contents.<link>
<link rel="stylesheet" type="text/css" href="url" title="description_of_style">[2]A less-common, but important, usage is to supply navigation hints consistently through use of microformats. Several common relationships are defined, that may be exposed to users through the browser interface rather than directly in the web page.
<link rel="next" href="url">head element may contain any number of link elements. The link element has attributes, but no contents.<basefont> (deprecated)
font elements. Deprecated in favor of stylesheets.<script>…</script>
script tags or may be given in a separate resource whose URL is specified with the script element's optional src attribute. [3]<style>…</style>
<style type="text/css">…</style>style tags or may be given in separate resources whose URLs are specified with @import directives of the form
<style> @import url; </style>. [4]<object>…</object>
head element, it could potentially be used to extract foreign data and associate it with the current document.<meta>
meta elements specify associative key-value pairs.meta elements can specify HTTP headers which should be sent before the actual content when the HTML page is served from Web server to client: for example,
<meta http-equiv="foo" content="bar">foo that has a value bar.meta element specifies name and associated content attributes describing aspects of the HTML page. To prevent possible ambiguity, an optional third attribute, scheme, may be supplied to specify a semantic framework that defines the meaning of the key and its value: for example,
<meta name="foo" content="bar" scheme="DC">meta element identifies itself as containing the foo element, with a value of bar, from the DC or Dublin Core resource description framework.Inline elements cannot be placed directly inside the body element; they must be wholly nested within block-level elements (see Block elements, below).
<em>…</em>
<strong>…</strong>
<q>…</q>
blockquote below). Quote elements may be nested. By the specification, the author should not include quotation marks. Rather, quotation marks — including nested quotation marks — should be rendered through stylesheet properties or the browser's default stylesheet. Practical concerns due to browser non-compliance may force authors to find work-arounds. The cite attribute gives the source, and must be a fully qualified URI.<q class='lengthy'>An inline quotation of significant length (say 25 words, for example) goes here...</q>.<cite>…</cite>
<dfn>…</dfn>
<abbr>…</abbr>
<acronym>…</acronym>
abbr element, but contains an acronym, like HTML.These elements are useful primarily for documenting computer code development and user interaction through differentiation of source code (<code>), source code variables (<var>), user input (<kbd>), and terminal output (<samp>).
<code>…</code>
Code snippet.<samp>…</samp>
<kbd>…</kbd>
<var>…</var>
<sub>…</sub> <sup>…</sup>
{vertical-align: sub} or {vertical-align: super}<del>…</del>
<ins>…</ins>
<del>'d text. Typically rendered underlined: Inserted text.ins and del elements may be used as block elements: containing other block and inline elements. However, these elements must still remain wholly within their parent element to maintain a well-formed HTML document. For example deleting text from the middle of one paragraph across several other paragraphs and ending in a final paragraph would need to use three separate del elements. Two del elements would be required as inline element to indicate the deletion of text in the first and last paragraphs, and a third, used as a block element, to indicate the deletion in the intervening paragraphs.<isindex> (deprecated)
isindex element requires server side support for indexing documents. Visually presents a one-line text input for keyword entry. When submitted, the query string is appended to the current URL and the document is displayed with these keywords highlighted. Generally if the server supports this feature it will add the isindex elements to documents without author intervention.<a>…</a>
href (hypertext reference[5]) attribute set to a URL; additionally the attribute title may be set to a hover box text, some informative text about the link:<a href="URL" title="additional information">link text</a>name attribute set, which preceded by a number sign ' # ', and appended to the URL, acts as a link target in a URI scheme (a "document fragment"), typically causing a Web browser to scroll directly to that point of the page. Any element can be made into an anchor by using the id attribute,[6] so using <a name="foo"> is not necessary.Also see the LINK element.
<img>
src attribute. The required alt attribute provides alternative text in case the image cannot be displayed. Alt is intended as alternative text, although Microsoft Internet Explorer renders it as a tooltip if no title is given; the title attribute is the tooltip text. It was proposed by Marc Andreessen.[7]<br> or <br />
<map>…</map><area>
<object>…</object>type attribute. This may be in any MIME-type the Web browser understands, such as an embedded page, code to be handled by a plug-in such as Flash, a Java applet, a sound file, etc.<param>object element. Using attributes such as name and value, each <param> sets a parameter for the object. Examples include width, height, font, background colour, etc, depending on what has been exposed in this way by the object's developers.<embed>…</embed> (proprietary)type attribute. Used for embedding Flash files, sound files, etc. This is a proprietary Netscape extension to HTML; <object> is the W3C standard method.<noembed>…</noembed> (proprietary)<applet>…</applet> (deprecated)<object> is now preferred.<span>…</span>id or class attribute, which can then be referenced from CSS or DOM call. Like most HTML elements, span also supports inline CSS in its optional style attribute.Many HTML elements are designed for altering the semantic structure or meaning of a document. Some are block-level, but most are inline and can be included in the normal flow of text.
<p>…</p>
<blockquote>…</blockquote>
cite attribute may give the source, and must be a fully qualified Uniform Resource Identifier. The blockquote element is often misunderstood. It is an element meant to contain quotations that are themselves block level. In other words, it contains a complete paragraph or many paragraphs. In HTML strict DTDs inline elements are prohibited from blockquote elements. For quotations not containing block level elements see the quote (q) element.<hr>
<h1>…</h1> <h2>…</h2> <h3>…</h3> <h4>…</h4> <h5>…</h5> <h6>…</h6>
<h1> for the highest-level heading (the major sections), <h2> for the next level down (sub-section), <h3> for a level below that, and so on. The lowest level heading is <h6>.<h1> as large bold text, and <h6> as small bold-faced text, but this can be overridden with CSS. The heading elements are not intended merely for creating large or bold text: they describe something about the document's structure and organization. Some programs use them to generate outlines and tables of contents.<dl>…</dl>
<dt>…</dt>
<dd>…</dd>
<ol>…</ol> and <ul>…</ul>
ol, the type attribute can be used to specify the kind of ordering, but CSS gives more control: {list-style-type: foo}. The default is Arabic numbering. For ul, CSS can be used to specify the list marker: {list-style-type: foo}. The default marker is a disc.<li>…</li>
<dir>…</dir> (deprecated)
<ul>.<menu>…</menu> (deprecated)
<ul> list, but badly supported. Deprecated in favor of <ul>.<table>…</table><tr>…</tr><th>…</th><td>…</td><colgroup>…</colgroup><col><caption>…</caption><thead>…</thead><tbody>…</tbody><tfoot>…</tfoot><thead>, this section may be repeated by the user agent if the table is split across pages (in printing or other paged media)These elements can be combined into a form or used separately as user-interface controls. Combined with a first-class javascript engine, these controls provide support for rich user interfaces.
HTML specifies the elements that make up a form, and the method by which it will be submitted. However, some form of script either server-side or client side must be used to process the user's input once it is submitted.
<form action="url">…</form>
<select name="xyz">…</select>
<option value="x">
select list.<input type="checkbox">
<input type="radio">
<input type="button">
<button> if possible (i.e. if the client supports it) which provides richer possibilities.<input type="submit">
<input type="image">
src tag.<input type="reset">
<input type="text">
size attribute specifies the default width of the input in character-widths. Maxlength sets the maximum number of characters the user can enter (which may be greater than size).<input type="password">
<input type="file">
<input type="hidden">
<label for="id">…</label>
<textarea rows="8">…</textarea>
cols and rows attributes. Text in between the tags appears in the text area when the page is loaded.<div>…</div>id or class attribute, which can then be referenced from CSS or DOM calls. Like most HTML elements, div also supports inline CSS in its optional style attribute.<pre>…</pre>
pre element signals that this white space should be rendered as authored. With the CSS properties: {white-space: pre; font-family: monospace;}, other elements can be presented in the same way. This element can contain any inline element except: image (img), object (object), big font size (big), small font size (small), superscript (sup), and subscript (sub).<address>…</address>
br to insert a new line within this element.<iframe>…</iframe>object element allows HTML authors to specify object for its presentation by a user agent [and] thus subsumes some of the tasks carried out by" iframe [8]object element, an iframe (inline frame) element may be the "target" frame for links defined in other elements and it may be "selected" by a browser as the focus for printing, viewing HTML source etc.[9]iframe element was not included in the version 1.1 XHTML specification, despite having never been formally deprecated. Those serving their web content as XHTML 1.1 must use the object element.An HTML document may contain a header and a body or a header and a frameset, but not both. For frames the Frames DTD must be used.
<frameset>…</frameset>rows and cols attributes.<frame>…</frame>src attribute appears inside.<noframes>…</noframes><body> element with child elements that will appear in web browsers that don't support frames.<iframe>…</iframe><body>, which embeds another HTML document. A similar effect can also be achieved using the object element. These approaches differ in some ways (World Wide Web Consortium [10]).See also Framing (World Wide Web).
The use of presentational markup is discouraged. The equivalent CSS should be used instead. Deprecated elements are only valid in the Transitional and Frameset variants of HTML 4.01 and XHTML1.0. They are invalid in the Strict variants of HTML 4.01, XHTML1.0 and XHTML 1.1. <b>…</b> and <i>…</i> are invalid in the current draft of XHTML2.0.
<center>…</center> (deprecated)<div> or another element with centering defined using CSS.<b>…</b>{font-weight: bold}<i>…</i>{font-style: italic}<big>…</big>{font-size: larger}.<small>…</small>{font-size: smaller}<s>…</s> (deprecated)<strike>…</strike> (deprecated){text-decoration: line-through}<tt>…</tt>{font-family: monospace}<u>…</u> (deprecated){text-decoration: underline}<font>…</font> (deprecated)Use <span> instead.
<font [color=color [size=size [face=face>…</font>color attribute, typeface with the face attribute, and absolute or relative size with the size attribute.Examples (all the examples are deprecated, use CSS equivalents if possible):
<font color="green">text</font> creates green text.<font color="#1f4099">text</font> creates text with hexadecimal color #1f4099.<font size="4">text</font> creates text with size 4. Sizes are from 1 to 7. The standard size is 3, unless otherwise specified in the <body> or other tags.<font size="+1">text</font> creates text with size 1 bigger than the standard.. <font size="-1">text</font> is opposite.<font face="Courier">text</font> makes text with Courier font.Equivalent CSS for font attributes:
<font size="N"> corresponds to {font-size: Yunits} (the HTML specification does not define the relationship between size N and unit-size Y, nor does it define a unit).<font color="red"> corresponds to {color: red}<font face="Courier"> corresponds to {font-family: "Courier"}These are unofficial presentational elements that may not be supported in all browsers.
<blink>…</blink> (unofficial){text-decoration: blink}<marquee>…</marquee> (unofficial)<blackface>…</blackface> (unofficial){font-weight: 900}; with some fonts (such as Arial or Gill Sans), using "black" or "ultra bold" variants are more effective.<shadow>…</shadow> (unofficial)<nobr>…</nobr> (unofficial){white-space: nowrap}<wbr> (unofficial)
<!-- A Comment -->
</html>. (However, placing comments before the DTD will throw Internet Explorer 6 into quirks mode. Any characters (except for whitespace) before the DTD will throw Internet Explorer 6 into quirks mode). None of its enclosed contents are rendered. For compatibility with some pre-1995 browsers, the contents of <style> and <script> elements are still sometimes surrounded by comment delimiters.