A codex (from the Latin caudex, meaning "trunk of a tree", "block of wood" or "book"), plural codices , is a book constructed of a number of sheets of paper, vellum, papyrus, or similar materials. The term is now usually only used of manuscript books, with hand-written contents, but describes the format that is now near-universal for printed books in the Western world. The book is usually bound by stacking the pages and fixing one edge to a spine, which may just be thicker paper (paperback or softback), or with stiff boards, called a hardback, or in elaborate historical examples a treasure binding.
At least in the Western world, the main alternative to the paged codex format for a long document is the continuous scroll, which was the dominant form of document in the Ancient World. Some codices are continuously folded like a concertina, in particular the Maya codices and Aztec codices, which are actually long sheets of paper or animal skin folded into pages. These do not really meet most current definitions of the "codex" form, but are so called by convention.
The Romans developed the form from wax tablets. The gradual replacement of the scroll by the codex has been called the most important advance in book making before the invention of the printing press. The codex transformed the shape of the book itself, and offered a form that has lasted to the present day (and continues to be used alongside e-paper). The spread of the codex is often associated with the rise of Christianity, which adopted the format for use with the Bible early on. First described by the 1st-century AD Roman poet Martial, who praised its convenient use, the codex achieved numerical parity with the scroll around 300 AD, and had completely replaced it throughout what was by then a Christianized Greco-Roman world by the 6th century.
The codex provides considerable advantages over other book formats:
The change from rolls to codices roughly coincides with the transition from papyrus to parchment as the preferred writing material, but the two developments are unconnected. In fact, any combination of codices and scrolls with papyrus and parchment is technically feasible and common in the historical record.
The codex began to replace the scroll almost as soon as it was invented. In Egypt, by the fifth century, the codex outnumbered the scroll by ten to one based on surviving examples. By the sixth century, the scroll had almost vanished as a medium for literature.
Technically, even modern paperbacks are codices, but publishers and scholars reserve the term for manuscript (hand-written) books produced from Late antiquity until the Middle Ages. The scholarly study of these manuscripts from the point of view of the bookbinding craft is called codicology. The study of ancient documents in general is called paleography.
The Romans used precursors made of reusable wax-covered tablets of wood for taking notes and other informal writings. Two ancient polyptychs, a pentaptych and octoptych, excavated at Herculaneum used a unique connecting system that presages later sewing on of thongs or cords.Julius Caesar may have been the first Roman to reduce scrolls to bound pages in the form of a note-book, possibly even as a papyrus codex. At the turn of the 1st century AD, a kind of folded parchment notebook called pugillares membranei in Latin became commonly used for writing in the Roman Empire.Theodore Cressy Skeat theorized that this form of notebook was invented in Rome and then spread rapidly to the Near East.
Codices are described in certain works by the Classical Latin poet, Martial. He wrote a series of five couplets meant to accompany gifts of literature that Romans exchanged during the festival of Saturnalia. Three of these books are specifically described by Martial as being in the form of a codex; the poet praises the compendiousness of the form (as opposed to the scroll), as well the convenience with which such a book can be read on a journey. In another poem by Martial, the poet advertises a new edition of his works, specifically noting that it is produced as a codex, taking less space than a scroll and more comfortable to hold in one hand. According to Theodore Cressy Skeat, this might be the first recorded known case of an entire edition of a literary work (not just a single copy) being published in codex form, though it was likely an isolated case and was not a common practice until a much later time.
In his discussion of one of the earliest parchment codices to survive from Oxyrhynchus in Egypt, Eric Turner seems to challenge Skeat's notion when stating, "...its mere existence is evidence that this book form had a prehistory", and that "early experiments with this book form may well have taken place outside of Egypt." Early codices of parchment or papyrus appear to have been widely used as personal notebooks, for instance in recording copies of letters sent (Cicero Fam. 9.26.1). The parchment notebook pages were commonly washed or scraped for re-use (called a palimpsest) and consequently, writings in a codex were often considered informal and impermanent.
As early as the early 2nd century, there is evidence that a codex--usually of papyrus--was the preferred format among Christians. In the library of the Villa of the Papyri, Herculaneum (buried in AD 79), all the texts (of Greek literature) are scrolls (see Herculaneum papyri). However, in the Nag Hammadi library, hidden about AD 390, all texts (Gnostic Christian) are codices. Despite this comparison, a fragment of a non-Christian parchment codex of Demosthenes' De Falsa Legatione from Oxyrhynchus in Egypt demonstrates that the surviving evidence is insufficient to conclude whether Christians played a major or central role in the development of early codices--or if they simply adopted the format to distinguish themselves from Jews. Regardless, the rise of the parchment codex is linked to the rise of Christianity: all of the Christian works found in 2nd century AD Egypt are in codex form, while 98 percent of the non-Christian works are not. 
The earliest surviving fragments from codices come from Egypt, and are variously dated (always tentatively) towards the end of the 1st century or in the first half of the 2nd. This group includes the Rylands Library Papyrus P52, containing part of St John's Gospel, and perhaps dating from between 125 and 160.
In Western culture, the codex gradually replaced the scroll. Between the 4th century, when the codex gained wide acceptance, and the Carolingian Renaissance in the 8th century, many works that were not converted from scroll to codex were lost. The codex improved on the scroll in several ways. It could be opened flat at any page for easier reading, pages could be written on both front and back (recto and verso), and the protection of durable covers made it more compact and easier to transport.
The ancients stored codices with spines facing inward, and not always vertically. The spine could be used for the incipit, before the concept of a proper title developed in medieval times. Though most early codices were made of papyrus, papyrus was fragile and supplies from Egypt, the only place where papyrus grew and was made into paper, became scanty. The more durable parchment and vellum gained favor, despite the cost.
The codices of pre-Columbian Mesoamerica (Mexico and Central America) had the same form as the European codex, but were instead made with long folded strips of either fig bark (amatl) or plant fibers, often with a layer of whitewash applied before writing. New World codices were written as late as the 16th century (see Maya codices and Aztec codices). Those written before the Spanish conquests seem all to have been single long sheets folded concertina-style, sometimes written on both sides of the local amatl paper. There are significant codices produced in the colonial era, with pictorial and alphabetic texts in Spanish or an indigenous language such as Nahuatl.
In East Asia, the scroll remained standard for far longer than in the Mediterranean world. There were intermediate stages, such as scrolls folded concertina-style and pasted together at the back and books that were printed only on one side of the paper. This replaced traditional Chinese writing mediums such as bamboo and wooden slips, as well as silk and paper scrolls. The evolution of the codex in China began with folded-leaf pamphlets in the 9th century, during the late Tang Dynasty (618-907), improved by the 'butterfly' bindings of the Song dynasty (960-1279), the wrapped back binding of the Yuan dynasty (1271-1368), the stitched binding of the Ming (1368-1644) and Qing dynasties (1644-1912), and finally the adoption of Western-style bookbinding in the 20th century. The initial phase of this evolution, the accordion-folded palm-leaf-style book, most likely came from India and was introduced to China via Buddhist missionaries and scriptures.
Among the experiments of earlier centuries, scrolls were sometimes unrolled horizontally, as a succession of columns. (The Dead Sea Scrolls are a famous example of this format.) This made it possible to fold the scroll as an accordion. The next step was then to cut the folios, sew and glue them at their centers, making it easier to use the papyrus or vellum recto-verso as with a modern book. Traditional bookbinders would call one of these assembled, trimmed and bound folios a codex to differentiate it from the case, which we now know as hard cover. Binding the codex was clearly a different procedure from binding the case.
The first stage in creating a codex is to prepare the animal skin. The skin is washed with water and lime, but not together, and it has to soak in the lime for a couple of days. The hair is removed and the skin is dried by attaching it to a frame called a herse. The parchment maker attaches the skin at points around the circumference. The skin attaches to the herse by cords. To prevent tearing, the maker wraps the area of the skin attached to the cord around a pebble called a pippin. After completing that, the maker uses a crescent shaped knife called a lunarium or lunellum to remove any remaining hairs. Once the skin completely dries, the maker gives it a deep clean and processes it into sheets. The number of sheets from a piece of skin depends on the size of the skin and the final product dimensions. For example, the average calfskin can provide three and half medium sheets of writing material. This can be doubled when folded into two conjoint leaves, also known as a bifolium. Historians have found evidence of manuscripts where the scribe wrote down the medieval instructions now followed by modern membrane makers. Defects can often be found in the membrane, whether from the original animal, human error during the preparation period, or from when the animal was killed. Defects can also appear during the writing process. Unless it is kept in perfect condition, defects can also appear later in the life of a manuscript.
First the membrane must be prepared. The first step is to set up the quires. The quire is a group of several sheets put together. Raymond Clemens and Timothy Graham point out, in "Introduction to Manuscript Studies", that "the quire was the scribe's basic writing unit throughout the Middle Ages":
"Pricking is the process of making holes in a sheet of parchment (or membrane) in preparation of it ruling. The lines were then made by ruling between the prick marks...The process of entering ruled lines on the page to serve as a guide for entering text. Most manuscripts were ruled with horizontal lines that served as the baselines on which the text was entered and with vertical bounding lines that marked the boundaries of the columns."
From the Carolingian period and all the way up to the Middle Ages, different styles of folding the quire came about. For example, in mainland Europe throughout the Middle Ages, the quire was put into a system in which each side folded on to the same style. The hair side met the hair side and the flesh side to the flesh side. This was not the same style used in the British Isles, where the membrane was folded so that it turned out an eight-leaf quire, with single leaves in the third and sixth positions. The next stage was tacking the quire. Tacking is when the scribe would hold together the leaves in quire with thread. Once threaded together, the scribe would then sew a line of parchment up the "spine" of the manuscript, as to protect the tacking.