A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Sentence-length palindromes may be written when allowances are made for adjustments to capital letters, punctuation, and word dividers, such as "A man, a plan, a canal, Panama!", "Was it a car or a cat I saw?" or "No 'x' in Nixon".
Composing literature in palindromes is an example of constrained writing.
The word "palindrome" was coined by the English playwright Ben Jonson in the 17th century from the Greek roots palin (πάλιν; "again") and dromos (δρóμος; "way, direction").
Palindromes date back at least to 79 AD, as a palindrome was found as a graffito at Herculaneum, a city buried by ash in that year. This palindrome, called the Sator Square, consists of a sentence written in Latin: "Sator Arepo Tenet Opera Rotas" ("The sower Arepo holds with effort the wheels"). It is remarkable for the fact that the first letters of each word form the first word, the second letters form the second word, and so forth. Hence, it can be arranged into a word square that reads in four different ways: horizontally or vertically from either top left to bottom right or bottom right to top left. As such, they can be referred to as palindromatic.
The palindromic Latin riddle "In girum imus nocte et consumimur igni" ("we go wandering at night and are consumed by fire") describes the behavior of moths. It is likely that this palindrome is from medieval rather than ancient times.
Byzantine Greeks often inscribed the palindrome, "Wash [the] sins, not only [the] face" ΝΙΨΟΝ ΑΝΟΜΗΜΑΤΑ ΜΗ ΜΟΝΑΝ ΟΨΙΝ ("Nīpson anomēmata mē mōnan ōpsin", engraving "ps" with the single Greek letter Ψ, psi), on baptismal fonts. This practice was continued in many English churches. Examples include the font at St. Mary's Church, Nottingham and also the font in the basilica of St. Sophia, Constantinople, the font of St. Stephen d'Egres, Paris; at St. Menin's Abbey, Orléans; at Dulwich College; and at the following churches: Worlingworth (Suffolk), Harlow (Essex), Knapton (Norfolk), St Martin, Ludgate (London), and Hadleigh (Suffolk).