Chivalry, or the chivalric code, is an informal, varying code of conduct developed between 1170 and 1220, never decided on or summarized in a single document, associated with the medieval institution of knighthood. The ideals of chivalry were popularized in medieval literature, especially the Matter of Britain and Matter of France, the former based on Geoffrey of Monmouth's Historia Regum Britanniae which introduced the legend of King Arthur, written in the 1130s.
The code of chivalry that developed in medieval Europe had its roots in earlier centuries. It arose in the Holy Roman Empire from the idealisation of the cavalryman—involving military bravery, individual training, and service to others—especially in Francia, among horse soldiers in Charlemagne's cavalry. The term derives from the Old French term chevalerie, which can be translated to "horse soldiery".Gautier states that knighthood emerged from the Moors (Muslims) as well as the Teutonic forests and was nurtured into civilization and chivalry by the Catholic Church.
Over time, its meaning in Europe has been refined to emphasise social and moral virtues more generally. The code of chivalry, as it stood by the Late Middle Ages, was a moral system which combined a warrior ethos, knightly piety, and courtly manners, all conspiring to establish a notion of honour and nobility.