The Mad Hatter character, alongside all the other fictional beings, first appears in Lewis Carroll’s 1865 novel Alice’s Adventures in Wonderland. In it, the Hatter explains to Alice that he and the March Hare are always having tea because when he tried to sing for the foul-tempered Queen of Hearts, she sentenced him to death for “murdering the time”, but he escapes decapitation. In retaliation, time (referred to as a “he” in the novel) halts himself in respect to the Hatter, keeping him and the March Hare stuck at 18:00 (or 6:00 pm) forever.
When Alice arrives at the tea party, the Hatter is characterised by switching places on the table at any given time, making short, personal remarks, asking unanswerable riddles and reciting nonsensical poetry, all of which eventually drives Alice away. The Hatter appears again as a witness at the Knave of Hearts’ trial, where the Queen appears to recognise him as the singer she sentenced to death, and the King of Hearts also cautions him not to be nervous or he will have him “executed on the spot”.