In Hamlet, instances of dramatic irony often come about as a result of Hamlet's tendency to only share certain motivations with the audience (and not with the other characters). For example, in Act 2, Scene 1, Ophelia and her father have a conversation about what they think is a change in Hamlet’s behavior. Ophelia has just had a frightening experience with Hamlet, and she is concerned that he has fallen mad or ill. In response, her father says:
This is the very ecstasy of love
Whose violent property fordoes itself
And leads the will to desperate undertakings
Polonius and Ophelia both conclude that Hamlet is behaving strangely because he has fallen madly in love with Ophelia. Because Polonius had previously encouraged Ophelia to spurn Hamlet’s advances, they see his behavior as evidence that he has become more invested. However, the audience has knowledge that Polonius and Ophelia don’t, and their understanding of Hamlet’s behavior creates tension in the scene.
Earlier in the play, Hamlet vows to start acting crazy, and the audience therefore understands that the source of his anger and confusion is the news that his father was murdered. His attempts to conceal his knowledge from the other characters in the play create dramatic irony, when the audience understands things about Hamlet’s behavior that other characters cannot. The dramatic irony is important to this scene because it fosters an environment in which dangerous misunderstandings can take place. Most of the dramatic irony in Hamlet stems from his decisions to conceal his real mental state from those around him. That lack of clarity also affects the audience and makes it difficult to determine what is actually motivating Hamlet.
A good example of the play's use of dramatic irony comes in Act 3, Scene 4, which is a significant turning point in the play. Driven by the escalation of tension, Hamlet arrives to confront his mother. Shortly into their conversation, when she begins to feel threatened, the Queen calls for help, and Hamlet realizes that someone is standing behind the curtain. The audience knows that Polonius is behind the curtain, but Hamlet doesn't, and without knowing who stands there, he kills him. The queen reacts with horror:
Queen: O me, what hast thou done?
Hamlet: Nay, I know not. Is it the King?
Queen: O, what a rash and bloody deed is this!
In this scene, dramatic irony is created by the fact that the Queen and the audience know that Polonius is behind the curtain, but Hamlet doesn’t know the identity of the "rat." Therefore, the audience realizes that Polonius is dead before Hamlet does. This is an important moment in the play because Hamlet’s action is the first decisive thing he has done in an effort to avenge his father and himself. Once he discovers that he has killed Polonius, his sense of right and wrong becomes further clouded. Immediately after, he is visited by the ghost, and Elsinore slips further into madness.
In Act 5, Scene 2, there is a violent altercation between Laertes and Hamlet. The final events of the play take place as the other characters gather to spectate, and these moments contain dramatic irony.
As is the case with many of the scenes in which groups of characters are present, the question of what information is known by whom becomes very relevant. In this case, the secrets kept have deadly consequences. Ultimately, it is a scene of great violence, and nearly everyone present dies. But before the characters gather, the audience watches as the King poisons the cup with the intention of killing Hamlet. What's more, Laertes has already vowed to enhance his odds in the duel by poisoning the tip of his sword, saying "I'll touch my point / With his contagion, that if I gall him slightly / It may be death." Because of this information, the play's final scene is rife with dramatic irony, as the audience knows important details that not all of the characters are aware of.
This use of dramatic irony makes the audience feel powerless as they watch the various characters unknowingly stumble into their own deaths. The senselessness of the violence is exacerbated by the fact that the audience can anticipate it. This is at its most extreme when the Queen accidentally poisons herself:
Queen: He’s fat and scant of breath.—Here, Hamlet, take my napkin; rub thy
brows. The Queen carouses to thy fortune, Hamlet.
Hamlet: Good madam.
King: Gertrude, do not drink.
Queen: I will, my lord; I pray you pardon me.
The audience and the King know that the Queen’s death is imminent even before the Queen herself knows it. This instance of dramatic irony thus ratchets up the sense of suspense and anticipation, as the audience helplessly watches the Queen walk into a trap.