
SGML (Standard Generalized Markup Language) is a standard for defining structured markup languages. It lets a document system describe elements and their relationships. Its history helps explain older publishing systems, XML, and earlier versions of HTML.
Follow the historical relationship
SGML was standardized as ISO 8879 in 1986. Its approach separates the structure of a document from a particular printed appearance. A publishing system can identify a title, section, warning, or citation and then use that structure in different output processes.
HTML 4 was defined as an SGML application. The HTML 4 introduction to SGML describes declarations, document type definitions, elements, attributes, and entities in that setting. This is a historical description of HTML 4's formal basis.
XML was designed as a simplified subset of SGML for exchanging structured information. The XML 1.0 specification defines its syntax and distinguishes well-formed documents from documents valid against declared constraints.
Modern HTML served as text/html follows the HTML Standard's own parsing rules. The HTML history and parsing specification explain its development and processing model. Choose the format and parser used by the actual system when interpreting a document.
Compare their jobs
| Format | Main role | Practical question |
|---|---|---|
| SGML | Framework for defining markup languages and document rules. | Which declaration, DTD, entities, and processing tools does this document set require? |
| XML | Syntax for structured documents with application-defined vocabularies. | Is it well-formed, and which schema or application rules must it satisfy? |
| HTML | A defined vocabulary and processing model for web documents. | Does the markup express the intended page structure and behave correctly in browsers? |
A document type definition, or DTD, describes permitted structures using declarations. For example, it can require a note to contain a recipient followed by a message. Presentation is a separate task: declaring a recipient element alone does not specify font size, layout, or how an application should deliver a notification.
Read structure and validation separately
This fictional XML document names a note, its recipient, and its message:
<note>
<recipient>Ada</recipient>
<message>Return the atlas.</message>
</note>The root element contains two children with matching start and end tags. Their names carry meaning only through the vocabulary and application that use them. A possible XML DTD for this small vocabulary is:
<!ELEMENT note (recipient, message)>
<!ELEMENT recipient (#PCDATA)>
<!ELEMENT message (#PCDATA)>The first declaration requires recipient followed by message. The other declarations allow parsed character data. The sample is well-formed as written; establishing validity against this DTD requires supplying the declarations to an appropriate validator. These are illustrative XML declarations, not a complete SGML processing environment.
If message appears before recipient, the document can remain well-formed XML but violate this DTD's ordering rule. If a closing tag is missing, it fails XML well-formedness. Neither successful parsing nor validation proves that “Ada” is the correct recipient: that is a separate application-level check.
In HTML, some end tags may be omitted under defined conditions, and the browser has specified error-recovery behavior. In XML, element names are case-sensitive and nesting must be well-formed. Similar-looking angle brackets do not make the processing rules interchangeable.
Work with a legacy document collection
- Identify the actual format, version, declarations, DTD or schema, and software used to process it.
- Keep representative source files together with entity files, catalogs, encodings, and other dependencies.
- Run the appropriate parser or validator on a small copy and record the exact diagnostics.
- For a conversion, compare structure and meaning: identifiers, cross-references, tables, special characters, and repeated content.
- Inspect rendered output as well as machine checks. A successful conversion should preserve the information readers rely on.
Changing a file extension is only a name change. A migration must account for the source's actual syntax and semantics. If entities or a DTD are missing, recover those dependencies before assuming the main document is corrupt.
For new ordinary web pages, start with modern HTML and its accessibility requirements. For a structured exchange, use the recipient system's specified vocabulary and validation rules. For an established SGML collection, the existing publishing workflow and migration requirements determine the tools. The useful distinction is which rules preserve the document's meaning throughout the process.