In Alice's Adventures in Wonderland, Alice attends a tea party hosted by a peculiar and irritable hat maker.
Author Lewis Carroll had a fantastical imagination. But the "Mad Hatter" character had a basis in reality.
At that time, many hat makers did behave strangely, leading to the term "mad as a hatter." Their odd behavior was caused by mercury poisoning.
From the 1700s through the early 1900s, hat factories used a mercury compound called mercuric nitrate. Long-term exposure to this poisonous compound led many hat makers to act as if insane or "mad." Symptoms included tremors, pathological shyness and extreme irritability.