'A' and 'An' and the Patterns of Their Use
Which gets used where?
The indefinite articles a and an pop up all over the place, introducing nouns that refer to people, creatures, or things not identified or specified. We see and hear them in phrases like "a dessert" and "an essential." Native speakers of English often give them no thought at all: the little words just slip off the tongue like nearly invisible thread linking more important lexical elements.
In a way, a and an are the same word. They both trace back to the Old English word ān, meaning "one," and they both have had the same indefinite article function since the days of Middle English.
And yet, they appear in slightly different contexts.
The patterns for which appears where are based on phonetics, but the patterns exist in writing as well as speech. When preceding a consonant sound, a is used: "a cake," "a slice of cake." Before a vowel sound, an is usual: "an enormous slice of cake," "an appropriately enormous slice of cake." But sometimes, typically in speech and more frequently in some dialects than others, a is found before a vowel sound: "a ambrosial cake."
The pattern exists for consonant sounds represented by a vowel letter as well: "a one-handed attempt at cake serving," "a united effort to distribute cake equitably." An is sometimes used in such contexts, but less now than it was in the past: "an unique opportunity for equitable ambrosial cake serving."
The letter H has historically inspired its own set of rules. When the word beginning with H has a first syllable that is unstressed or only weakly stressed, both a and an are used: "a hilarious joke used to distract us during an horrific cake theft." This is, however, less true than it used to be; a is now the typical choice before words beginning with H no matter their stress patterns. This is even true for the most famous examples: the word historic and its relations. While "an historic cake theft" and "an historical perspective on the theft of cake" will likely not earn you the opprobrium of your readers/listeners, "a historic" and "a historical" are by significant margins more popular. Do with that what you will.
Also H-related: in the King James Version of the Old Testament, you will find an used before H in a stressed syllable as well: "an huntress," "an hundred." In modern speech and writing this is rarer than even the most ambrosial cake.