What's a word to describe a self-referential text?

Solution 1:

Your question practically contains the answer. This technique is called self-reference. So the text is described as self-referential. This does not only occur in literature:

In the context of language, self-reference is used to denote a statement that refers to itself or its own referent. The most famous example of a self-referential sentence is the liar sentence:

  • “This sentence is not true.”

Self-reference is often used in a broader context as well. For instance, a picture could be considered self-referential if it contains a copy of itself

enter image description here

and a piece of literature could be considered self-referential if it includes a reference to the work itself. (plato.stanford.edu)

About the use of self-reference in literature, Wikipedia explains:

Self-reference occurs in literature and film when an author refers to his or her own work in the context of the work itself. Examples include Miguel de Cervantes' Don Quixote, Shakespeare's A Midsummer Night's Dream and The Tempest and Twelfth Night.

As an aside, I will add that self-reference is closely related with metafiction:

Metafiction is a form of fiction which emphasises its own constructedness in a way that continually reminds the audience to be aware they are reading or viewing a fictional work. Metafiction is self-conscious about language, literary form, and story-telling, and works of metafiction directly or indirectly draw attention to their status as artifacts.