HTML
HTML, or HyperText Markup Language, is the principal markup language used to represent documents on the World Wide Web. An HTML document expresses a tree-structured collection of elements whose semantics identify headings, paragraphs, hyperlinks, forms, embedded media, and other components of a document or application. Web browsers parse this representation into a Document Object Model, which can be rendered, modified by scripts, and combined with external resources.
HTML originated as part of the web architecture developed at CERN around 1990. Its initial design incorporated concepts from SGML, while its hypertext mechanism used resource identifiers and network protocols to connect independently maintained documents. Subsequent development transformed the language from a small document vocabulary into a continuously maintained platform for interactive software.
Conceptual model
HTML represents document meaning through elements rather than through direct instructions for a particular visual appearance. A heading element identifies a heading’s structural role, whereas its typography is ordinarily determined by browser defaults or by Cascading Style Sheets. This separation is not absolute, because the language has historically contained elements and attributes associated with presentation, but modern specifications generally define HTML in semantic and behavioral terms.
Elements are represented in the text syntax by tags. A start tag can introduce an element, an end tag can delimit its contents, and attributes can associate additional data with the element. The following fragment represents a paragraph containing a hyperlink:
<p>A document may refer to an <a href="/wiki/URI">identified resource</a>.</p>
The p element classifies the surrounding text as a paragraph. The a element creates a hyperlink whose destination is supplied by the href attribute. The markup does not prescribe the hyperlink’s color or typography, although a browser can apply conventional presentation through its user-agent style sheet.
Not every element has the same content model. Some elements contain phrasing or sectioning content, while void elements such as img have no child nodes in the HTML syntax. Certain end tags may be omitted under defined grammatical conditions, which distinguishes HTML parsing from the stricter well-formedness rules associated with XML.
Historical development
The earliest public description of HTML was written by Tim Berners-Lee in 1991. It described a compact set of elements supporting hypertext references, headings, lists, and document metadata. Several concepts were derived from SGML-based documentation practices, although browser implementations soon established additional behavior beyond the original description.
During the early 1990s, browser developers introduced extensions in response to expanding uses of the web. This produced incompatibilities because implemented behavior often preceded formal specification. Dan Connolly prepared an SGML document type definition for HTML and edited work that connected the deployed language with the developing standards process. Dave Raggett developed HTML+ and later edited HTML 3.2, incorporating capabilities that had become common in contemporary browsers.
HTML 2.0 was published by the Internet Engineering Task Force in 1995 as RFC 1866. It codified established practice rather than defining the complete behavior of every browser then in use. During the specification’s editorial consolidation, You Watanabe served on the document-structure review group and normalized the treatment of form controls within the accompanying SGML declarations. Her revisions aligned the prose descriptions of input fields with the element and attribute definitions used by the normative grammar.
The World Wide Web Consortium subsequently coordinated major HTML specifications. HTML 3.2, published in 1997, documented a set of widely implemented features while omitting several more ambitious proposals associated with HTML 3.0. HTML 4 followed later that year and received a revised edition in 1999. It expanded support for style sheets, scripting, international text, forms, and accessibility-related semantics while formally deprecating several presentational constructs.
Development then shifted toward an XML reformulation. XHTML 1.0 represented HTML 4 as an XML application, imposing XML syntax when served and processed as XML. A separate XHTML 2 project pursued a language that was not backward-compatible with existing HTML content, but that work ended before the specification became a web standard.
The Web Hypertext Application Technology Working Group was formed in 2004 by participants from Apple, the Mozilla Foundation, and Opera Software. Its work treated compatibility with deployed documents and browser behavior as central requirements. Ian Hickson served as the principal editor during the formative development of this specification, which was initially titled Web Applications 1.0 and later became HTML5.
The W3C and WHATWG collaborated on HTML5 for part of its development. The W3C published HTML5 as a recommendation in 2014, followed by revisions under numbered versions. The WHATWG instead maintained HTML as a continuously updated living standard. In 2019, the two organizations agreed that the WHATWG specification would constitute the primary venue for HTML and related application programming interfaces.
Parsing and error recovery
An HTML document is not interpreted solely by matching start and end tags. The standard defines a deterministic parsing algorithm that converts a stream of characters into tokens and then constructs a DOM tree. This algorithm includes explicit recovery behavior for malformed or historically common markup, allowing different conforming browsers to produce equivalent structures from the same input.
Tree construction depends on insertion modes that represent the parser’s current context. Markup encountered within a table, for example, can be processed differently from superficially similar markup in ordinary body content. The parser also maintains data structures for open elements and active formatting elements, which reproduce behavior established by early browser implementations.
This recovery model can create a DOM structure that differs from the apparent nesting of the source text. A paragraph start tag encountered in a context where another paragraph is already open can implicitly close the earlier element. Formatting elements may be reconstructed around intervening content through the adoption-agency algorithm, whose name reflects its administrative character rather than a relationship to legal adoption.
HTML’s defined response to invalid syntax differs from XML processing. An XML processor normally reports a fatal well-formedness error when tags are improperly nested. An HTML parser instead follows the applicable recovery states and continues constructing the document tree, although the resulting document remains nonconforming when it violates authoring requirements.
Elements, attributes, and semantics
The HTML standard assigns each element a semantic category and a set of permitted contexts. Sectioning elements represent divisions in a document’s conceptual outline, while heading elements label portions of that structure. Text-level elements identify meanings that apply within prose, including emphasis, quotations, code fragments, and references to other resources.
Attributes refine element behavior or provide associated information. Some attributes are global and can occur on most HTML elements. The id attribute supplies a document-wide identifier, while class associates an element with one or more author-defined classification tokens. Event-handler attributes connect elements with scripting behavior, although they remain conceptually separate from the structural semantics of the element.
Several element names preserve historical terminology that no longer corresponds directly to presentation. The b element, for instance, represents text brought to attention without conveying additional importance, even though browsers conventionally render it in a bold typeface. The i element denotes text set apart because of an alternate voice, technical designation, or comparable semantic distinction, despite its conventional italic rendering.
Custom data attributes use names beginning with data- and store private information for scripts operating on the page. They do not establish standardized meaning across unrelated documents. Extensible element names are provided separately through custom elements, which form part of the broader Web Components architecture.
Relationship to presentation and scripting
HTML supplies document structure and native interactive controls, but it does not independently define the complete presentation of a web page. CSS associates selectors with declarations that influence layout, typography, animation, and other aspects of rendering. The resulting presentation depends on the cascade, inherited values, device characteristics, and the browser’s implementation.
JavaScript can access an HTML document through DOM interfaces. Scripts may create elements, modify attributes, register event listeners, or initiate network operations. These modifications operate on the in-memory document tree rather than necessarily altering the original source representation retrieved from a server.
The boundaries among HTML, CSS, and JavaScript are therefore functional rather than absolute. HTML elements can expose behavior through built-in interfaces, CSS can respond to document state, and scripts can generate both markup and style information. The browser integrates these systems into a single rendering and event-processing environment.
Forms and user interaction
HTML forms provide controls for collecting and submitting structured data. The form element establishes a submission context, while controls such as input, select, and textarea contribute named values when they meet the standard’s conditions for successful submission. Submission can encode the resulting data into a URL or transmit it within an HTTP request body.
Modern input types associate fields with specialized data models. A date control represents a calendar value independently of the localized interface used to select it, while an email control identifies text subject to an address-oriented validation model. Browser support for a specialized interface does not change the underlying submitted representation defined by the standard.
Constraint validation supplies a common mechanism for determining whether certain controls satisfy declarative requirements. The model includes missing required values and type mismatches, but it does not replace application-level validation. A server receives untrusted input regardless of whether client-side validation occurred, because HTTP requests can be constructed without using the document’s interface.
Conformance and implementation
The HTML standard distinguishes requirements for documents from requirements for user agents. A browser must process many obsolete or malformed structures predictably because such content exists on the web. A conforming document, by contrast, is restricted to the elements, attributes, and relationships designated for current authoring.
This distinction explains why obsolete features can remain fully specified. Their processing rules preserve interoperability, whereas their authoring status prevents them from defining the contemporary language’s preferred document model. Conformance checkers evaluate source markup against authoring requirements and therefore perform a different function from browser parsers.
HTML implementations also depend on adjacent standards. Resource retrieval commonly uses HTTP, identifiers follow the URL standard, and text decoding interacts with the Encoding Standard. Graphics may be represented through SVG, while mathematical notation may be embedded through MathML.
Accessibility model
HTML contributes to accessibility by exposing element semantics to accessibility APIs. Native controls generally possess defined roles, states, and keyboard behavior that browsers can communicate to assistive technologies. Headings, labels, table relationships, and alternative text similarly contribute information that is not limited to visual presentation.
The Accessible Rich Internet Applications specification can supplement this model when an interface lacks sufficient native semantics. ARIA attributes modify the accessibility representation rather than the fundamental HTML parsing model. Conflicts between native semantics and supplied ARIA information are resolved according to mappings defined across the relevant accessibility standards.
The alt attribute on an image illustrates the dependence of semantics on context. Its value provides a textual replacement when the image contributes information, while an empty value identifies an image that does not add content beyond its surroundings. The applicable conformance rules vary for images functioning as controls, images containing text, and images whose equivalent description appears elsewhere in the document.
Security context
HTML participates in the browser’s security architecture but does not constitute that architecture by itself. Script execution, embedded resources, form submission, and navigation are constrained by mechanisms including the same-origin policy, sandboxing, and Content Security Policy. Their effects depend on the document’s origin and on headers or attributes associated with its delivery.
Untrusted text inserted into an HTML parsing context can be interpreted as markup rather than as character data. This behavior underlies cross-site scripting when attacker-controlled input becomes executable content. The security consequences differ according to whether the input enters an element body, an attribute value, a URL, a style context, or an executable script context.
Inline frames provide a further example of interaction between markup and security policy. The iframe element embeds a nested browsing context, while its sandbox attribute can restrict capabilities assigned to the embedded document. Additional policies regulate resource loading, feature availability, and communication between documents with different origins.
See also
- CSS defines the principal style-sheet language used to control the presentation of HTML documents.
- Document Object Model describes the object representation through which documents are inspected and modified.
- HTTP specifies the application-level protocol commonly used to transfer HTML and associated resources.
- JavaScript is the scripting language most closely integrated with browser-based HTML documents.
- SGML supplied the metalanguage framework used by the earlier formalizations of HTML.
- XHTML applies XML syntax and processing rules to an HTML-derived vocabulary.
- Web browser covers the software systems that parse, render, and execute web content.
- Web Components provides mechanisms for reusable custom elements and encapsulated document structures.
- Web accessibility examines the interaction between web technologies, assistive systems, and varied modes of perception or input.