With its atmosphere of music, love, and merriment, Twelfth Night is a quintessential Shakespearean comedy, and it bears more than a passing resemblance to other plays in the same genre. Twins and mistaken identity are as crucial to the plot of Twelfth Night as they are to the plot of The Comedy of Errors, and the crossdressing for which Twelfth Night is famous also occurs in As You Like It and The Merchant of Venice, as well as the frame story for The Taming of the Shrew. As in Much Ado About Nothing and A Midsummer Night's Dream, misunderstandings and love triangles initially keep the lovers apart, but these conflicts are all eventually resolved.
It is often said that all Shakespearean comedies end with a wedding, but it is actually far more typical for them to end just before the wedding. This type of ending allows the characters to exist forever in a moment of blissful anticipation and prevents the audience from having to consider the many hardships that marriage will bring. At the end of Twelfth Night, Viola's marriage to Orsino has only been suggested, and since she remains in men's clothing, the play's final image is of two men in an ostensibly homoerotic pairing.
Although Twelfth Night is a comedy, not all of the characters receive happy endings. Antonio's love for Sebastian is unrequited, and Malvolio storms away swearing revenge on the other characters, casting a pall over the otherwise joyful proceedings. Feste's ending song, which laments the inevitability of growing old, is also far from celebratory.