What SGML is

SGML (Standard Generalized Markup Language) is the international standard ISO 8879 from 1986. You do not write documents in it directly. It is a set of rules for creating markup languages, a so-called metalanguage. SGML is used to define which tags a document may contain and how they can be combined.

SGML grew out of GML, a language developed at IBM in the 1960s and 1970s for consistent processing of technical documentation.

The core idea: content separate from presentation

SGML describes what the individual parts of a document mean (heading, paragraph, chapter, note), not how they should look. The appearance is decided only when the document is displayed or printed. The same document can therefore be printed as a book, shown on screen or processed by a computer. This idea carried over to the web, where HTML defines the structure and CSS the appearance.

SGML, HTML and XML

  • HTML was originally created as an application of SGML, a language defined according to its rules. Today's HTML5 has its own parsing rules, but the tags and structure remain.
  • XML is a simplified subset of SGML from 1998. It can do similar things but is much easier to process, which is why it spread to feeds, sitemaps and data exchange.

What they share are tags in angle brackets, for example <heading>…</heading>, and the document type definition (DTD). The <!DOCTYPE html> line at the top of every web page is a leftover from SGML.

Where SGML is used today

You will not come across it directly on the everyday web. It survives mainly in large technical documentation systems where documents are maintained for decades, for example in aviation, the military, the automotive industry and publishing. Most new projects, however, now use XML.

Why it is worth knowing

The way web pages are built comes from SGML: tags, heading structure and design kept separate from content. If you understand that, it is easier to see why both SEO and accessibility need clean, semantic HTML.

Clean code on your website

When building websites, I make sure the HTML structure is correct, so browsers, search engines and screen readers can all understand it.