Spanish Accent Marks
Spanish uses accent marks (or diacritics) to show which syllable should be stressed, to differentiate homographs (words with the same spelling but different meanings), and to break up dipthongs (two vowels that combine into one syllable).
All linguistic jargon aside, the rules for using accent marks in Spanish are pretty straightforward. It’s really just a matter of memorization.
Others have already explained the rules much better than I can, so I’ll just include some links. These three sites all have the same information. The first one is my favorite, but I found it helpful to skim over the other two as well:
And if you ever need to use Spanish on the computer, see this page on How to Type Accented Characters.

