HTML

Hypertext Markup Language (HTML) is the standard for documents designed to be displayed in a. It can be assisted by technologies such as (CSS) and s such as.

s receive HTML documents from a or from local storage and  the documents into multimedia web pages. HTML describes the structure of a web page and originally included cues for the appearance of the document.

s are the building blocks of HTML pages. With HTML constructs, and other objects such as  may be embedded into the rendered page. HTML provides a means to create s by denoting structural for text such as headings, paragraphs, lists,, quotes and other items. HTML elements are delineated by tags, written using. Tags such as and  directly introduce content into the page. Other tags such as surround and provide information about document text and may include other tags as sub-elements. Browsers do not display the HTML tags, but use them to interpret the content of the page.

HTML can embed programs written in a such as, which affects the behavior and content of web pages. Inclusion of CSS defines the look and layout of content. The (W3C), former maintainer of the HTML and current maintainer of the CSS standards, has encouraged the use of CSS over explicit presentational HTML

Markup
HTML markup consists of several key components, including those called tags (and their attributes), character-based data types, character references and entity references. HTML tags most commonly come in pairs like and, although some represent empty elements and so are unpaired, for example. The first tag in such a pair is the start tag, and the second is the end tag (they are also called opening tags and closing tags).

Another important component is the HTML , which triggers rendering.

The following is an example of the classic : The text between and  describes the web page, and the text between  and  is the visible page content. The markup text defines the browser page title.

The Document Type Declaration is for HTML5. If a declaration is not included, various browsers will revert to "" for rendering.

Elements
HTML documents imply a structure of nested s. These are indicated in the document by HTML tags, enclosed in angle brackets thus:.

In the simple, general case, the extent of an element is indicated by a pair of tags: a "start tag" and "end tag". The text content of the element, if any, is placed between these tags.

Tags may also enclose further tag markup between the start and end, including a mixture of tags and text. This indicates further (nested) elements, as children of the parent element.

The start tag may also include attributes within the tag. These indicate other information, such as identifiers for sections within the document, identifiers used to bind style information to the presentation of the document, and for some tags such as the used to embed images, the reference to the image resource.

Some elements, such as the, do not permit any embedded content, either text or further tags. These require only a single empty tag (akin to a start tag) and do not use an end tag.

Many tags, particularly the closing end tag for the very commonly used paragraph element, are optional. An HTML browser or other agent can infer the closure for the end of an element from the context and the structural rules defined by the HTML standard. These rules are complex and not widely understood by most HTML coders.

The general form of an HTML element is therefore:. Some HTML elements are defined as empty elements and take the form. Empty elements may enclose no content, for instance, the tag or the inline  tag. The name of an HTML element is the name used in the tags. Note that the end tag's name is preceded by a slash character,, and that in empty elements the end tag is neither required nor allowed. If attributes are not mentioned, default values are used in each case.

Element examples
Header of the HTML document:. The title is included in the head, for example: Headings: HTML headings are defined with the to  tags:

Paragraphs: Line breaks:. The difference between and  is that    without altering the semantic structure of the page, whereas   sections the page into s. Note also that   is an empty element in that, although it may have attributes, it can take no content and it may not have an end tag. This is a link in HTML. To create a link the tag is used. The  attribute holds the URL address of the link. Inputs: There are many possible ways a user can give input/s like: Comments: attribute sets the link's target. For example, the HTML markup, will render the word " Wikipedia " as a hyperlink. To render an image as a hyperlink, an  element is inserted as content into the   element. Like,   is an empty element with attributes but no content or closing tag. .

Attributes
Most of the attributes of an element are, separated by  and written within the start tag of an element after the element's name. The value may be enclosed in single or double quotes, although values consisting of certain characters can be left unquoted in HTML (but not XHTML). Leaving attribute values unquoted is considered unsafe. In contrast with name-value pair attributes, there are some attributes that affect the element simply by their presence in the start tag of the element, like the  attribute for the   element.

There are several common attributes that may appear in many elements :


 * The  attribute provides a document-wide unique identifier for an element. This is used to identify the element so that stylesheets can alter its presentational properties, and scripts may alter, animate or delete its contents or presentation. Appended to the URL of the page, it provides a globally unique identifier for the element, typically a sub-section of the page. For example, the ID "Attributes" in.
 * The  attribute provides a way of classifying similar elements. This can be used for  or presentation purposes. For example, an HTML document might semantically use the designation  to indicate that all elements with this class value are subordinate to the main text of the document. In presentation, such elements might be gathered together and presented as footnotes on a page instead of appearing in the place where they occur in the HTML source. Class attributes are used semantically in s. Multiple class values may be specified; for example  puts the element into both the   and the   classes.
 * An author may use the  attribute to assign presentational properties to a particular element. It is considered better practice to use an element's   or   attributes to select the element from within a, though sometimes this can be too cumbersome for a simple, specific, or ad hoc styling.
 * The  attribute is used to attach subtextual explanation to an element. In most  this attribute is displayed as a.
 * The  attribute identifies the natural language of the element's contents, which may be different from that of the rest of the document. For example, in an English-language document:

The abbreviation element,, can be used to demonstrate some of these attributes:

This example displays as HTML ; in most browsers, pointing the cursor at the abbreviation should display the title text "Hypertext Markup Language."

Most elements take the language-related attribute  to specify text direction, such as with "rtl" for right-to-left text in, for example,,  or.

Character and entity references
As of version 4.0, HTML defines a set of 252 s and a set of 1,114,050 s, both of which allow individual characters to be written via simple markup, rather than literally. A literal character and its markup counterpart are considered equivalent and are rendered identically.

The ability to "escape" characters in this way allows for the characters  and   (when written as   and , respectively) to be interpreted as character data, rather than markup. For example, a literal  normally indicates the start of a tag, and   normally indicates the start of a character entity reference or numeric character reference; writing it as   or   or   allows   to be included in the content of an element or in the value of an attribute. The double-quote character, when not used to quote an attribute value, must also be escaped as  or   or   when it appears within the attribute value itself. Equivalently, the single-quote character, when not used to quote an attribute value, must also be escaped as  or   (or as   in HTML5 or XHTML documents) when it appears within the attribute value itself. If document authors overlook the need to escape such characters, some browsers can be very forgiving and try to use context to guess their intent. The result is still invalid markup, which makes the document less accessible to other browsers and to other s that may try to parse the document for purposes for example.

Escaping also allows for characters that are not easily typed, or that are not available in the document's, to be represented within element and attribute content. For example, the acute-accented , a character typically found only on Western European and South American keyboards, can be written in any HTML document as the entity reference   or as the numeric references   or  , using characters that are available on all keyboards and are supported in all character encodings. character encodings such as are compatible with all modern browsers and allow direct access to almost all the characters of the world's writing systems.

Data types
HTML defines several s for element content, such as script data and stylesheet data, and a plethora of types for attribute values, including IDs, names, URIs, numbers, units of length, languages, media descriptors, colors, character encodings, dates and times, and so on. All of these data types are specializations of character data.

Document type declaration
HTML documents are required to start with a (informally, a "doctype"). In browsers, the doctype helps to define the rendering mode—particularly whether to use.

The original purpose of the doctype was to enable parsing and validation of HTML documents by SGML tools based on the (DTD). The DTD to which the DOCTYPE refers contains a machine-readable grammar specifying the permitted and prohibited content for a document conforming to such a DTD. Browsers, on the other hand, do not implement HTML as an application of SGML and by consequence do not read the DTD.

does not define a DTD; therefore, in HTML5 the doctype declaration is simpler and shorter:

An example of an HTML 4 doctype

This declaration references the DTD for the "strict" version of HTML 4.01. SGML-based validators read the DTD in order to properly parse the document and to perform validation. In modern browsers, a valid doctype activates standards mode as opposed to.

In addition, HTML 4.01 provides Transitional and Frameset DTDs,. Transitional type is the most inclusive, incorporating current tags as well as older or "deprecated" tags, with the Strict DTD excluding deprecated tags. Frameset has all tags necessary to make frames on a page along with the tags included in transitional type.