Chivalry, or the chivalric code, is a code of conduct associated with the medieval institution of knighthood which developed between 1170 and 1220. 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 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.