Homonyms are words that are pronounced the same way. They often share the same spelling. However, each word in a set of homonyms has a different meaning and may have distinct origins, as well. One example of this phenomenon occurs when a word can be used both as a noun and a verb. For example, you can scratch your "back" or you can "back" a candidate in an election. Sometimes the words express the same part of speech but still have different meanings. The word "bat" refers to both the long, wooden implement used in baseball games and to the winged mammal.
Homographs are words that are written the same way, but differ in meaning and in pronunciation. An example occurs with the word "refuse." If you emphasize the first syllable, then you are speaking about garbage. If you emphasize the second syllable, then you mean the verb synonymous with "deny" or "negate."
It is easy to confuse these two situations. In many examples of homographs, for instance, the difference between the two words is related to part of speech, just as it is with homonyms. However, pronunciation is used with homographs to indicate the difference in meaning, whereas with homonyms you must hear the context to understand the word's intent. Homonyms only need to sound the same, but homographs must be spelled the same.
There is overlap among these and other categories of word groupings, which include homophones (words that sound the same but have different spelling and/or meaning) and heteronyms (a specific type of homograph).