HOME

TheInfoList



OR:

An HTML element is a type of
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
(HyperText Markup Language) document component, one of several types of HTML nodes (there are also text nodes, comment nodes and others). The first used version of HTML was written by
Tim Berners-Lee Sir Timothy John Berners-Lee (born 8 June 1955), also known as TimBL, is an English computer scientist best known as the inventor of the World Wide Web. He is a Professorial Fellow of Computer Science at the University of Oxford and a profe ...
in 1993 and there have since been many versions of HTML. The most commonly used version is HTML 4.01, which became official standard in December 1999. An HTML document is composed of a
tree In botany, a tree is a perennial plant with an elongated stem, or trunk, usually supporting branches and leaves. In some usages, the definition of a tree may be narrower, including only woody plants with secondary growth, plants that are ...
of simple HTML
nodes In general, a node is a localized swelling (a "knot") or a point of intersection (a vertex). Node may refer to: In mathematics *Vertex (graph theory), a vertex in a mathematical graph *Vertex (geometry), a point where two or more curves, lines, ...
, such as text nodes, and HTML elements, which add
semantics Semantics (from grc, σημαντικός ''sēmantikós'', "significant") is the study of reference, meaning, or truth. The term can be used to refer to subfields of several distinct disciplines, including philosophy, linguistics and compu ...
and formatting to parts of document (e.g., make text bold, organize it into paragraphs, lists and tables, or embed
hyperlink In computing, a hyperlink, or simply a link, is a digital reference to data that the user can follow or be guided by clicking or tapping. A hyperlink points to a whole document or to a specific element within a document. Hypertext is text ...
s and images). Each element can have
HTML attribute HTML attributes are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of an ''HTML element type''. An attribute either modifies the default functionality of an element type or provides fu ...
s specified. Elements can also have content, including other elements and text.


Concepts


Elements vs. tags

As is generally understood, the position of an element is indicated as spanning from a start tag and is terminated by an end tag. This is the case for many, but not all, elements within an HTML document. The distinction is explicitly emphasised in ''HTML 4.01 Specification'': Similarly the W3C Recommendation ''HTML 5.1 2nd Edition'' explicitly says: and: As HTML (before HTML5) is based on
SGML The Standard Generalized Markup Language (SGML; ISO 8879:1986) is a standard for defining generalized markup languages for documents. ISO 8879 Annex A.1 states that generalized markup is "based on two postulates": * Declarative: Markup should d ...
, its parsing also depends on the Document Type Definition (DTD), specifically an HTML DTD (e.g. HTML 4.01). The DTD specifies which element types are possible (i.e. it defines the set of element types) and also the valid combinations in which they may appear in a document. It is part of general SGML behavior that, where only one valid structure is (per the DTD), its explicit statement in any given document is not generally required. As a simple example, the tag indicating the start of a paragraph element should be complemented by a tag indicating its end. But since the DTD states that paragraph elements cannot be nested, an HTML document fragment is thus inferred to be equivalent to . (If one paragraph element cannot contain another, any currently open paragraph must be closed before starting another.) Because this implication is based on the combination of the DTD and the individual document, it is not usually possible to infer elements from document tags but only by using an SGML—or HTML—aware parser with knowledge of the DTD.
HTML5 HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HT ...
creates a similar result by defining what tags can be omitted.


SGML vs. XML

SGML is complex, which has limited its widespread understanding and adoption.
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
was developed as a simpler alternative. Although both can use the DTD to specify the supported elements and their permitted combinations as document structure, XML parsing is simpler. The relation from tags to elements is always that of parsing the actual tags included in the document, without the implied closures that are part of SGML. HTML as used on the current web is likely to be either treated as XML, by being
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
, or as
HTML5 HTML5 is a markup language used for structuring and presenting content on the World Wide Web. It is the fifth and final major HTML version that is a World Wide Web Consortium (W3C) recommendation. The current specification is known as the HT ...
; in either case the parsing of document tags into
Document Object Model The Document Object Model (DOM) is a cross-platform and language-independent interface that treats an XML or HTML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a docum ...
(DOM) elements is simplified compared to legacy HTML systems. Once the DOM of elements is obtained, behavior at higher levels of interface (example: screen rendering) is identical or nearly so.


%block; vs. box

Part of this CSS presentation behavior is the notion of the " box model". This is applied to those elements that CSS considers to be "block" elements, set through the CSS declaration. HTML also has a similar concept, although different, and the two are very frequently confused. %block; and %inline; are groups within the HTML DTD that group elements as being either "block-level" or "inline". This is used to define their nesting behavior: block-level elements cannot be placed into an inline context. This behavior cannot be changed; it is fixed in the DTD. Block and
inline elements Inline is commonly used to mean "in a line", "aligned" or "placed within a line or sequence". Topics that feature "inline" in their names include: * Inline citation (here meaning "within a line of text") * Inline engine * Inline hockey * Inline ...
have the appropriate and different
CSS Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone t ...
behaviors attached to them by default, including the relevance of the box model for particular element types. Note though that this CSS behavior can, and frequently is, changed from the default. Lists with are %block; elements and are presented as block elements by default. However, it is quite common to set these with CSS to display as an inline list.


Overview


Syntax

In the HTML syntax, most elements are written with a start tag and an end tag, with the content in between. An HTML tag is composed of the name of the element, surrounded by
angle bracket A bracket is either of two tall fore- or back-facing punctuation marks commonly used to isolate a segment of text or data from its surroundings. Typically deployed in symmetric pairs, an individual bracket may be identified as a 'left' or 'r ...
s. An end tag also has a slash after the opening angle bracket, to distinguish it from the start tag. For example, a paragraph, which is represented by the element, would be written as:

In the HTML syntax, most elements are written ...

However, not all of these elements the end tag, or even the start tag, to be present. Some elements, the so-called ''
void elements Void may refer to: Science, engineering, and technology * Void (astronomy), the spaces between galaxy filaments that contain no galaxies * Void (composites), a pore that remains unoccupied in a composite material * Void, synonym for vacuum, ...
'', do not have an end tag. A typical example is the (hard line-break) element. A void element's behavior is predefined, and it cannot contain any content or other elements. For example, an address would be written as:

P. Sherman
42 Wallaby Way
Sydney

When using
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
, it is required to open and close all elements, including void elements. This can be done by placing an end tag immediately after the start tag, but this is not legal in HTML 5 and will lead to two elements being created. An alternative way to specify that it is a void element, which is compatible with both XHTML and HTML 5, is to put a / at the of the tag (not to be confused with the / at the of a closing tag).

P. Sherman
42 Wallaby Way
Sydney

HTML attribute HTML attributes are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of an ''HTML element type''. An attribute either modifies the default functionality of an element type or provides fu ...
s are specified inside the start tag. For example, the element, which represents an abbreviation, expects a title attribute within its opening tag. This would be written as: abbr. Informally, HTML elements are sometimes referred to as "tags" (an example of
synecdoche Synecdoche ( ) is a type of metonymy: it is a figure of speech in which a term for a part of something is used to refer to the whole ('' pars pro toto''), or vice versa ('' totum pro parte''). The term comes from Greek . Examples in common En ...
), though many prefer the term ''tag'' strictly in reference to the markup delimiting the start and end of an element. Element (and attribute) names may be written in any combination of upper or lower case in HTML, but must be in lower case in XHTML.
XHTML 1.0 Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior t ...
§4.2
The canonical form was upper-case until
HTML 4 The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScrip ...
, and was used in HTML specifications, but in recent years, lower-case has become more common.


Types of element

There are three kinds of
HTML The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
elements: normal elements, raw text elements, and void elements. usually have both a start tag and an end tag, although for some elements the end tag, or both tags, can be omitted. It is constructed in a similar way: * a ''start tag'' () marking the beginning of an element, which may incorporate any number of
HTML attribute HTML attributes are special words used inside the opening tag to control the element's behaviour. HTML attributes are a modifier of an ''HTML element type''. An attribute either modifies the default functionality of an element type or provides fu ...
s; * some amount of ''content'', including text and other elements; * an ''end tag'', in which the element name is prefixed with a
slash Slash may refer to: * Slash (punctuation), the "/" character Arts and entertainment Fictional characters * Slash (Marvel Comics) * Slash (''Teenage Mutant Ninja Turtles'') Music * Harry Slash & The Slashtones, an American rock band * Nash th ...
: . (also known as text or text-only elements) are constructed with: * a ''start tag'' (in the form ) marking the beginning of an element, which may incorporate any number of HTML attributes; * some amount of text ''content'', but no elements (all tags, apart from the applicable end tag, will be interpreted as content); * an ''end tag'', in which the element name is prefixed with a slash: . In some versions of HTML, the end tag is optional for some elements. The end tag is required in
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
. An example is the element, which must not contain other elements (including markup of text), only text. (also sometimes called empty elements, single elements or stand-alone elements) only have a start tag (in the form ), which contains any HTML attributes. They may not contain any children, such as text or other elements. For compatibility with
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated. While HTML, prior ...
, the HTML specification allows an optional space and slash ( is permissible). The slash is required in
XHTML Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (