Originally (prior to the mid-5th C, including during the periods of persecution), the term cardinalis referred to every priest either incardinated (lt: from cardus, a hinge turned on a fixed axis) to a See, or intitulated (lt: titus, entitled to, adj: titular) to one.
An incardinated priest would be physically resident at a given See, and a titular priest is one to whom a title is granted, but may or may not be resident.
After the mid-5th C, the term cardinal would be applied to the Archpriest (head priest) of many of the Major Sees, which included the quasi-Dioceses (titulus) of Rome itself.
By the mid-9th C, seeing the relatively closeness of the Cardinals to the Holy See, Pope St. Stephen III ordered that a Cardinal-Bishop would say the Mass at the Altar of St. Peter in the Lateran Basilica.
After the late middle ages, seeing the importance of many of the metropolitan Dioceses (that is, Diocese who had suffrigan Diocese ‘beneath’ them), many of the Metropolitan Archbishops, Patriarchs of historical Sees would be given a titular parish in Rome to affirm their closeness to the Pope. Also, various Dicasteries of the Roman Curia would be headed by a Cardinal with a titular Church. While these are often associated with various Sees and Curial offices, they are by no means invariable: the Pope can grant or withhold a Cardinalatial See from a given individual by his own authority.