In text, LaTeX builds accented letters from a command and the base letter: the acute \'e (é), grave \`e (è), circumflex \^e (ê), umlaut or diaeresis \"o (ö), tilde \~n (ñ), cedilla \c{c} (ç), caron \v{s} (š), breve \u{a} (ă), Hungarian double acute \H{o} (ő), dot above \.z (ż), macron \=a (ā), dot below \d{a}, bar below \b{a}, ring \r{a} (å) and ogonek \k{e} (ę). Whole letters have their own commands: \l (ł), \o (ø), \ae (æ) and \ss (ß). To accent an i or j, use the dotless forms \i and \j, as in \'{\i} for í, so the accent does not collide with the dot.
Math mode uses a separate set that sits over a variable rather than a letter: \hat{x}, \bar{x}, \vec{v}, \tilde{x}, \dot{x} and \ddot{x} for derivatives, \acute, \grave, \breve and \check. For more than one character, base LaTeX has the stretching \widehat{xy} and \widetilde{xy}, plus \overline{z} for conjugates and \overrightarrow{AB} for vectors; none of them needs amsmath.
Since 2018 LaTeX reads UTF-8 by default, so you can type é, ö or ñ directly in the source (older setups need \usepackage[utf8]{inputenc}). Add \usepackage[T1]{fontenc} so accented letters are single glyphs that hyphenate and copy correctly instead of being composed from two pieces. For a worked example see our guide to Spanish characters and accents in LaTeX, or the overview of special characters in LaTeX. Click any card below to copy its command.
\hat{x}\widehat{xyz}\tilde{x}\widetilde{xyz}\dot{x}\ddot{x}\dddot{x}\bar{x}\overline{xyz}\underline{xyz}\vec{x}\overrightarrow{AB}\overleftarrow{AB}\overleftrightarrow{AB}\acute{x}\grave{x}\breve{x}\check{x}\mathring{x}\overbrace{x+y}^{\text{sum}}\underbrace{x+y}_{\text{sum}}\cancel{x}\boxed{x}