Only look at the pronunciation of the next word
The choice of a or an is always based on the pronunciation of the word immediately following the article.
The grammatical structure of the phrase is irrelevant. The spelling of the word is also irrelevant, except insofar as it relates to the pronunciation. Since there are a lot of cases where English spelling does not relate to the pronunciation in a straightforward way, spelling is an unreliable guide in this area.
If you’re unsure of the pronunciation of a word or phrase, you can look it up in a dictionary that has a pronunciation guide. There are many good online dictionaries available for free; you can see a list of some of them at the following post: What good reference works on English are available?
The main rule in modern standard English: a before consonant sounds, an before vowel sounds
Fortunately, there is a very simple rule that you can follow that will never lead you astray, as long as you keep in mind the very important fact that it is based purely on pronunciation and never based on spelling.
In modern standard English, both written and spoken, we use a before words that start with consonant sounds when they are transcribed phonemically, and an before words that start with vowel sounds when they are transcribed phonemically.
What is a consonant and what is a vowel?
As I've already said, this has nothing to do with ordinary English spelling. You need to look at a phonemic transcription of the word (most of these are based on the International Phonetic Alphabet).
Some of the letters used in the transcription many be unfamiliar to you. If so, it may be helpful to use the lists of IPA letters and example words in the following lecture notes: The Vowels and Consonants of English, by Nigel Musk. If you've chosen to use a dictionary that uses a different system from the IPA, then you should look to see if it has a table of the sounds used in its transcription system where they are classified by type.
It's generally fairly intuitive, but keep in mind that the semivowels /w/ (the “w” sound in wet) and /j/ (the “y” sound in yes) are considered consonant sounds, despite their phonetic similarity to vowels.
Example words, some with misleading spellings
Here are some examples:
- “an apple,” because apple is the next word after the article, it is pronounced /æpl̩/, and /æ/ is a vowel
- “a green apple,” because green is the next word after the article, it is pronounced /griːn/, and /g/ is a consonant
- “a Pop-Tart,” because Pop-Tart is the next word after the article, it is pronounced ˈpɑpˌtɑrt/, and /p/ is a consonant
- “an enormous Pop-Tart,” because enormous is the next word after the article, it is pronounced /ɪˈnɔrməs/, and /ɪ/ is a vowel
- “an hour,” because hour is the next word after the article, it is pronounced /aʊɚ/, and /aʊ/ is a vowel
- “a user,” because user is the next word after the article, it is pronounced /juːzɚ/, and /j/ is a consonant
- “an orange T-shirt,” because orange is the next word after the article, it is pronounced /ɔrəndʒ/, and /ɔ/ is a vowel
- “a one-time offer,” because one is the next word after the article, it is pronounced /wʌn/, and /w/ is a consonant
- “an 11,” because 11 is the next word after the article, it is pronounced /ɪˈlɛvn̩/, and /ɪ/ is a vowel
- “an FAQ,” because FAQ is the next word after the article, it can be pronounced /ˌɛfˌeɪˈkjuː/, and /ɛ/ is a vowel
- “a FAQ,” because FAQ is the next word after the article, it can be pronounced /fæk/, and /f/ is a consonant (see the following question for more information about the pronunciation of "FAQ": What is the commonly accepted pronunciation of FAQ?)
“An historic”: Optional class of exceptions to the main rule
As I said earlier, following the main standard rule is always acceptable. However, there is a set of words where it’s also acceptable, but optional, to follow a different rule.
Before words that start with the consonant /h/ followed by an unstressed syllable, such as historical, the article an may be used instead of a. This may have originally been due to speakers dropping the "h" in this position, but in modern English the sound /h/ is not necessarily dropped in "an historical" and like phrases.
"A apple": possible for some people in spontaneous speech, but not standard
Sometimes, you might hear people use "a" before a word that starts with a vowel, with a glottal stop in between the two vowels. For example, someone might say "a apple" (/əˈʔæpl̩/). However, this is not standard, and is only common for some speakers. For other speakers, it might only occur as an occasional disfluency. In writing, "a" before a word that starts with a vowel may reflect this phenomenon, but is often just an error resulting from edits that change word order or word choice.
Historical usage of “a” and “an” may be different
In earlier stages of English, these articles were not always distributed in the same way as they are now. Be aware of this if you're reading an old text, such as the King James Bible.
See the following questions for more information:
Another good resource on this topic is the following blog post by waiwai93: Articles: “A” vs. “An”