The Heptarchy is a collective name applied to the seven kingdoms of Anglo-Saxon England from the Anglo-Saxon settlement of Britain in the 5th century until the 8th century consolidation into the four kingdoms of Mercia, Northumbria, Wessex and East Anglia.
The term 'Heptarchy' (from the Greek ἑπταρχία, 'heptarchia'; from ἑπτά, 'hepta': "seven"; ἀρχή, 'arche': "reign, rule" and the suffix -ία, '-ia') alludes to the tradition that there were seven Anglo-Saxon kingdoms, usually enumerated as: East Anglia, Essex, Kent, Mercia, Northumbria, Sussex, and Wessex.
The historiographical tradition of the 'seven kingdoms' is medieval, first recorded by Henry of Huntingdon in his Historia Anglorum (12th century); the term Heptarchy dates to the 16th century.
By convention, the Heptarchy period lasted from the end of Roman rule in Britain in the 5th century, until most of the Anglo-Saxon kingdoms came under the overlordship of Egbert of Wessex in 829. This approximately 400-year period of European history is often referred to as the Early Middle Ages or, more controversially, as the Dark Ages. Although heptarchy suggests the existence of seven kingdoms, the term is just used as a label of convenience and does not imply the existence of a clear-cut or stable group of seven kingdoms. The number of kingdoms and sub-kingdoms fluctuated rapidly during this period as competing kings contended for supremacy.
In the late 6th century, the king of Kent was a prominent lord in the south. In the 7th century, the rulers of Northumbria and Wessex were powerful. In the 8th century, Mercia achieved hegemony over the other surviving kingdoms, particularly with "Offa the Great". Yet, as late as the reigns of Eadwig and Edgar (955–75), it was still possible to speak of separate kingdoms within the English population.
Alongside the seven kingdoms, a number of other political divisions also existed, such as the kingdoms (or sub-kingdoms) of: Bernicia and Deira within Northumbria; Lindsey in present-day Lincolnshire; the Hwicce in the southwest Midlands; the Magonsæte or Magonset, a sub-kingdom of Mercia in what is now Herefordshire; the Wihtwara, a Jutish kingdom on the Isle of Wight, originally as important as the Cantwara of Kent; the Middle Angles, a group of tribes based around modern Leicestershire, later conquered by the Mercians; the Hæstingas (around the town of Hastings in Sussex); and the Gewisse, a Saxon tribe in what is now southern Hampshire that later developed into the kingdom of Wessex.
The decline of the Heptarchy and the eventual emergence of the kingdom of England was a drawn-out process, taking place over the course of the 9th to 10th centuries. Over the course of the 9th century, the Danish enclave at York expanded into the Danelaw, with about half of England under Danish rule. The English unification under Alfred the Great was a reaction to the threat by the common enemy. In 886, Alfred retook London, and the Anglo-Saxon Chronicle says that "all of the English people (all Angelcyn) not subject to the Danes submitted themselves to King Alfred."
The unification of the kingdom of England was complete only in the 10th century, following the expulsion of Eric Bloodaxe as king of Northumbria. Æthelstan was the first to be King of all England.
Further information: Anglo-Saxon royal genealogies
The four main kingdoms in Anglo-Saxon England were:
The other main kingdoms, which were conquered by others entirely at some point in their history, before the unification of England, are:
Other minor kingdoms and territories:
Whilst heraldry did not exist in its modern form at the time, arms were attributed to the kingdoms of the Anglo-Saxon heptarchy from the 12th or 13th century onward. Some of these were based on existing description, for example with the attributed arms of Northumbria deriving from a description in the 8th century Historia Ecclesiastica Gentis Anglorum, which describes a flag flown over the tomb of King Oswald of Northumbria as "made of gold and purple", which eventually came to be gold and red. 
The Kingdom of Essex, for instance, was assigned a red shield with three notched swords (or "seaxes"). This coat was used by the counties of Essex and Middlesex until 1910, when the Middlesex County Council applied for a formal grant from the College of Arms (The Times, 1910). Middlesex was granted a red shield with three notched swords and a "Saxon Crown". Essex County Council was granted the arms without the crown in 1932. Similarly, the modern county of Kent uses the arms of the Kingdom of the same name, and the Mercian Cross of St Albans is still used in the arms of city of St Albans.