Imagine a centuries-old manuscript sitting in a library archive. Scholars want to study it, search it, compare it with other works, and preserve it for future generations. But a simple scanned image or plain typed copy strips away vital information: which words were corrections, where one page ended, who wrote a marginal note, or which character spoke a line in a play. The Text Encoding Initiative (TEI) solves exactly this problem. It is a set of guidelines that tells scholars how to mark up texts so that computers can read, search, and analyse them without losing the rich detail that makes a text meaningful. For students of library and information science, TEI sits at the heart of how the humanities have moved into the digital age.
Table of Contents
- What is the Text Encoding Initiative?
- Why machine-readable texts matter
- The TEI markup language: from SGML to XML
- A flexible and customisable system
- Structure of TEI documents
- The teiHeader: metadata that travels with the text
- The text element and its hierarchy
- Applications of TEI in the humanities
- Why libraries and institutions rely on TEI
What is the Text Encoding Initiative?
The Text Encoding Initiative is a community-developed standard for representing texts in digital form. Its central output is a set of Guidelines that specify encoding methods for machine-readable texts, chiefly in the humanities, social sciences, and linguistics. In simpler terms, TEI is an agreed-upon way of “tagging” the parts of a text so that a computer understands what each part is, a heading, a stanza, a personal name, a date, a correction, and much more.
TEI is not a single piece of software you download. It is best understood as several things at once. It is a set of guidelines for encoding humanities texts, a standards organisation that maintains the encoding language, an international consortium that supports this work, and a worldwide community of projects and scholars who use these guidelines in practice. The TEI Consortium is a nonprofit membership organisation made up of universities, research projects, and individual scholars who collectively develop and refine the standard.
The project began in 1987, when scholars working with early digital texts realised they faced a kind of digital Tower of Babel. Each project invented its own way of marking up texts, which meant that material created by one team could rarely be reused by another. The TEI was established to develop hardware- and software-independent methods for encoding humanities data in electronic form, so that scholarly work could be shared, preserved, and reused across institutions and decades. Since the first full guidelines appeared in the mid-1990s, libraries, museums, publishers, and individual researchers have used TEI to present texts for online research, teaching, and long-term preservation.
Why machine-readable texts matter
A “machine-readable” text is one that a computer can interpret structurally, not just display as a flat string of characters. When a poem is encoded in TEI, the computer knows which lines belong to which stanza, which words are the title, and which note was added by an editor. This makes powerful operations possible: searching every speech by a single character across an entire play, generating an index of all the place names mentioned in a travel diary, or comparing different manuscript versions of the same work. Without structured encoding, the computer sees only undifferentiated text and none of this analysis is possible.
The TEI markup language: from SGML to XML
TEI works through markup, the practice of inserting tags into a text to describe its structure and meaning. Markup languages such as HTML are used to structure and describe data rather than to perform calculations like a programming language. TEI is a specialised markup vocabulary designed specifically to describe written texts.
When TEI was first developed in the late 1980s, it was built on SGML (Standard Generalized Markup Language), an international standard for marking up documents that had been published by the ISO in 1986. SGML was the natural foundation because it allowed encoders to maintain complex document structures. As technology evolved, the World Wide Web Consortium released a final recommendation for XML, the Extensible Markup Language, in February 1998. It quickly became clear that TEI needed to be re-expressed in this newer formalism to survive.
This shift unfolded across several versions of the Guidelines. TEI P3, released in 1994, became the de facto standard for humanities text encoding and was built on SGML. TEI P4 in 2002 was essentially P3 re-expressed in XML, while TEI P5, released in November 2007, was a thorough overhaul that introduced new modules for manuscript description, character encoding, graphics, and standoff annotation. P5 remains the current major version, with the Consortium publishing incremental updates roughly twice a year. Today, the TEI Guidelines collectively define a particular type of XML format, so TEI and XML are intrinsically related: TEI is essentially a detailed set of rules for writing XML to describe texts.
A flexible and customisable system
One of TEI’s defining strengths is its flexibility. The full Guidelines comprise many hundreds of elements and attributes covering an enormous range of textual features. No single project needs all of them. Instead, TEI is designed to be customised: a user adapts the standard to the specific type of document they are working with, whether that is medieval poetry, modern correspondence, or a linguistic corpus. This customisability is a core principle of the TEI’s architecture and is what allows the same underlying standard to serve such diverse scholarly needs.
As an encoding language, TEI can describe both the physical characteristics of a text, such as line breaks, pagination, and special characters, and its intellectual content, such as classifying subjects, tagging people, places, and events, adding linguistic markup, and recording editorial commentary. This dual capability is what makes it so valuable for serious scholarship.
Structure of TEI documents
Understanding how a TEI document is organised is essential. Like every XML document, a TEI file has a single root element that contains everything else in a strict hierarchy, with no overlapping tags. In TEI, that root is the <TEI> element. Within it, every TEI document has at least two parts: a header, represented by the <teiHeader> element, which contains metadata describing the document, and the text itself, usually represented by the <text> element.
The basic skeleton looks like this:
The teiHeader: metadata that travels with the text
The header is what distinguishes TEI from ordinary XML markup. It is a structured description of the document that answers questions like who wrote the text, when, where it was published, what the source material was, and under what licence it is shared. The <teiHeader> is the first mandatory element of a TEI document and always appears immediately after the opening <TEI> tag, ensuring that the metadata is considered an integral part of the electronic text rather than a detachable add-on.
The backbone of the header is the <fileDesc> (file description) element, which is required. According to the TEI guidelines, a file description minimally contains the title of the electronic text inside <titleStmt>, information about its publication inside <publicationStmt>, and bibliographic details about the source document inside <sourceDesc>. Together these record where the digital text came from and how it should be cited, which is the kind of bibliographic control that connects TEI directly to core library science. Notably, TEI header elements can be mapped to corresponding MARC fields, linking digital text encoding to established library cataloguing practice.
The text element and its hierarchy
Below the header sits the <text> element, which contains a single text of any kind, whether a poem, a play, a novel, a collection of essays, a dictionary, or a sample from a larger corpus. The <text> element is typically divided into a front (preliminary material like a title page or preface), a body (the main content), and a back (appendices, indexes, or notes).
Within the body, TEI handles structural subdivisions elegantly. Different cultures and document types name their divisions differently, one tradition’s “chapter within a book” may be another’s “section within a part”. Rather than imposing rigid names, TEI offers a single flexible element, <div>, for any structural subdivision, with attributes such as @type to specify whether a given division functions as a chapter, a volume, or something else. This approach reflects a model that scholars describe as an ordered hierarchy of content objects: the idea that a text can be decomposed into neatly nested parts, much like branches on a family tree. This model works remarkably well for a large proportion of documents, though TEI also provides techniques for the trickier cases where structures overlap, such as page breaks that cut across stanzas.
Applications of TEI in the humanities
The impact of TEI on digital scholarship has been significant. Historically it was used to create digital encodings of existing historical texts, but in recent years it has increasingly been used for born-digital content as well, including scholarly journals and online editions.
The most prominent application is the digital scholarly edition. Scholars use TEI to produce richly annotated versions of literary and historical works where every editorial decision is transparent and machine-actionable. A TEI edition can record variant readings across multiple manuscripts, expand abbreviations, mark uncertain passages, and link the text to images of the original source, all within a single structured file.
TEI is also widely used for encoding correspondence. The encoding of letters has a long tradition in the community, with early projects developing models for marking up features specific to letters, such as the sender, the addressee, closing phrases, and postscripts. This allows researchers to build searchable archives of historical correspondence and to study networks of communication at scale.
Why libraries and institutions rely on TEI
For libraries, museums, and archives, TEI serves three connected purposes: research, teaching, and preservation. Because the encoding is hardware- and software-independent and based on the open XML standard, a TEI document created today should remain readable for decades, long after specific software has become obsolete. This durability is precisely what cultural heritage institutions need. TEI files also support advanced retrieval: a digitised collection encoded in TEI can be searched by personal name, place, date, or genre, transforming a static archive into a dynamic research tool.
It is worth being realistic about the trade-offs. TEI encoding is detailed and labour-intensive, and because tag choices depend on human interpretation, two projects encoding the same text may make different decisions, which limits automatic interoperability. Even so, for serious humanities scholarship that demands precision, transparency, and longevity, TEI remains the leading standard, supported by a global community that continues to refine it.
What do you think? If you were tasked with digitising a rare regional manuscript collection in your library, would the long-term preservation benefits of TEI justify the considerable time and expertise its encoding demands? And as more humanities content is born digital rather than scanned from print, how might the role of a standard like TEI change in the coming decade?
References
- https://tei-c.org/
- https://tei-c.org/about/history/
- https://www.tei-c.org/release/doc/tei-p5-doc/en/html/AB.html
- https://www.contextractor.com/xml-tei/
- https://en.wikipedia.org/wiki/Text_Encoding_Initiative
- https://books.openedition.org/oep/681?lang=en
- https://guides.library.illinois.edu/xml/tei-header
- https://teibyexample.org/exist/tutorials/TBED02v00.htm
- https://www.tei-c.org/release/doc/tei-p5-doc/en/html/DS.html
- https://tei-c.org/release/doc/tei-p5-doc/en/html/SG.html

Leave a Reply