Twelfth Night, or What You Will is a romantic comedy by William Shakespeare, believed to have been written around 1601-1602 as a Twelfth Night's entertainment for the close of the Christmas season. The play centres on the twins Viola and Sebastian, who are separated in a shipwreck. Viola (who is disguised as Cesario) falls in love with Duke Orsino, who in turn is in love with Countess Olivia. Upon meeting Viola, Countess Olivia falls in love with her thinking she is a man.
The play expanded on the musical interludes and riotous disorder expected of the occasion, with plot elements drawn from the short story "Of Apollonius and Silla" by Barnabe Rich, based on a story by Matteo Bandello. The first recorded public performance was on 2 February 1602, at Candlemas, the formal end of Christmastide in the year's calendar. The play was not published until its inclusion in the 1623 First Folio.
Viola is shipwrecked on the coast of Illyria and she comes ashore with the help of a Captain. She has lost contact with her twin brother, Sebastian, whom she believes to be drowned, and with the aid of the Captain, she disguises herself as a young man under the name Cesario and enters the service of Duke Orsino. Duke Orsino has convinced himself that he is in love with Olivia, who is mourning the recent deaths of her father and brother. She refuses to see entertainments, be in the company of men, or accept love or marriage proposals from anyone, the Duke included, until seven years have passed. Duke Orsino then uses 'Cesario' as an intermediary to profess his passionate love before Olivia. Olivia, however, falls in love with 'Cesario', setting her at odds with her professed duty. In the meantime, Viola has fallen in love with Duke Orsino, creating a love triangle: Viola loves Duke Orsino, Duke Orsino loves Olivia, and Olivia loves Viola disguised as Cesario.
In the comic subplot, several characters conspire to make Olivia's pompous steward, Malvolio, believe that Olivia has fallen for him. This involves Olivia's riotous uncle, Sir Toby Belch; another would-be suitor, a silly squire named Sir Andrew Aguecheek; her servants Maria and Fabian; and her melancholy fool, Feste. Sir Toby and Sir Andrew engage themselves in drinking and revelry, thus disturbing the peace of Olivia's household until late into the night, prompting Malvolio to chastise them. Sir Toby famously retorts, "Dost thou think, because thou art virtuous, there shall be no more cakes and ale?" (Act II, Scene III).
Sir Toby, Sir Andrew, and Maria plan revenge on Malvolio. They convince Malvolio that Olivia is secretly in love with him by planting a love letter, written by Maria in Olivia's handwriting. It asks Malvolio to wear yellow stockings cross-gartered—a colour and fashion that Olivia actually hates—to be rude to the rest of the servants, and to smile constantly in the presence of Olivia. Malvolio finds the letter and reacts in surprised delight. He starts acting out the contents of the letter to show Olivia his positive response. Olivia is shocked by the changes in Malvolio and agreeing that he seems mad, leaves him to be cared for by his tormentors. Pretending that Malvolio is insane, they lock him up in a dark chamber. Feste visits him to mock his insanity, both disguised as a priest and as himself.
Meanwhile, Viola's twin, Sebastian, has been rescued by Antonio, a sea captain who previously fought against Orsino, yet who accompanies Sebastian to Illyria, despite the danger, because of his admiration for Sebastian. Sebastian's appearance adds the confusion of mistaken identities to the comedy. Taking Sebastian for 'Cesario', Olivia asks him to marry her, and they are secretly married in a church. Finally, when 'Cesario' and Sebastian appear in the presence of both Olivia and Orsino, there is more wonder and confusion at their physical similarity. At this point, Viola reveals her identity and is reunited with her twin brother.
The play ends in a declaration of marriage between Duke Orsino and Viola, and it is learned that Sir Toby has married Maria. Malvolio swears revenge on his tormentors and stalks off, but Orsino sends Fabian to placate him.
Illyria, the exotic setting of Twelfth Night, is important to the play's romantic atmosphere.
Illyria was an ancient region of the Western Balkans whose coast (the eastern coast of the Adriatic Sea which is the only part of ancient Illyria which is relevant to the play) covered (from north to south) the coasts of modern-day Slovenia, Croatia, Bosnia and Herzegovina, Montenegro, and Albania. It included the city-state of the Republic of Ragusa which has been proposed as the setting.
Illyria may have been suggested by the Roman comedy Menaechmi, the plot of which also involves twins who are mistaken for each other. Illyria is also referred to as a site of pirates in Shakespeare's earlier play, Henry VI, Part 2. The names of most of the characters are Italian but some of the comic characters have English names. Oddly, the "Illyrian" lady Olivia has an English uncle, Sir Toby Belch.
It has been noted that the play's setting also has other English allusions such as Viola's use of "Westward ho!", a typical cry of 16th century London boatmen, and also Antonio's recommendation to Sebastian of "The Elephant" as where it is best to lodge in Illyria (The Elephant was a pub not far from the Globe Theatre).
The play is believed to have drawn extensively on the Italian production Gl'ingannati (or The Deceived Ones), collectively written by the Accademia degli Intronati in 1531. It is conjectured that the name of its male lead, Orsino, was suggested by Virginio Orsini, Duke of Bracciano, an Italian nobleman who visited London in the winter of 1600 to 1601.
Another source story, "Of Apollonius and Silla", appeared in Barnabe Riche's collection, Riche his Farewell to Militarie Profession conteining verie pleasaunt discourses fit for a peaceable tyme (1581), which in turn is derived from a story by Matteo Bandello.
"Twelfth Night" is a reference to the twelfth night after Christmas Day, called the Eve of the Feast of Epiphany. It was originally a Catholic holiday and therefore, like other Christian feast days, an occasion for revelry. Servants often dressed up as their masters, men as women and so forth. This history of festive ritual and Carnivalesque reversal, based on the ancient Roman festival of Saturnalia at the same time of year (characterized by drunken revelry and inversion of the social order; masters became slaves for a day, and vice versa), is the cultural origin of the play's gender confusion-driven plot.
The actual Elizabethan festival of Twelfth Night would involve the antics of a Lord of Misrule, who before leaving his temporary position of authority, would call for entertainment, songs and mummery; the play has been regarded as preserving this festive and traditional atmosphere of licensed disorder. This leads to the general inversion of the order of things, most notably gender roles. The embittered and isolated Malvolio can be regarded as an adversary of festive enjoyment and community, led by Sir Toby Belch, "the vice-regent spokesman for cakes and ale" and his partner in a comic stock duo, the simple and constantly exploited Sir Andrew Aguecheek.
The full title of the play is Twelfth Night, or What You Will. Subtitles for plays were fashionable in the Elizabethan era, and though some editors place The Merchant of Venice's alternative title, The Jew of Venice, as a subtitle, this is the only Shakespearean play to bear one when first published.
The play was probably finished between 1600 and 1601, a period suggested by the play's referencing of events which happened during that time. A law student, John Manningham, who was studying in the Middle Temple in London, described the performance on 2 February 1602 (Candlemas) which took place in the hall of the Middle Temple at the formal end of Christmastide in the year's calendar, and to which students were invited. This was the first recorded public performance of the play. The play was not published until its inclusion in the First Folio in 1623.
Viola is not alone among Shakespeare's cross-dressing heroines; in Shakespeare's theatre, convention dictated that adolescent boys play the roles of female characters, creating humour in the multiplicity of disguise found in a female character who for a while pretended at masculinity. Her cross dressing enables Viola to fulfil usually male roles, such as acting as a messenger between Orsino and Olivia, as well as being Orsino's confidant. She does not, however, use her disguise to enable her to intervene directly in the plot (unlike other Shakespearean heroines such as Rosalind in As You Like It and Portia in The Merchant of Venice), remaining someone who allows "Time" to untangle the plot. Viola's persistence in transvestism through her betrothal in the final scene of the play often engenders a discussion of the possibly homoerotic relationship between Viola and Orsino.
As the very nature of Twelfth Night explores gender identity and sexual attraction, having a male actor play Viola enhanced the impression of androgyny and sexual ambiguity. Some modern scholars believe that Twelfth Night, with the added confusion of male actors and Viola's deception, addresses gender issues "with particular immediacy". They also accept that the depiction of gender in Twelfth Night stems from the era's prevalent scientific theory that females are simply imperfect males. This belief explains the almost indistinguishable differences between the sexes reflected in the casting and characters of Twelfth Night.
At Olivia's first meeting with "Cesario" (Viola) in I.V she asks her "Are you a comedian?" (an Elizabethan term for "actor"). Viola's reply, "I am not that I play", epitomising her adoption of the role of "Cesario" (Viola), is regarded as one of several references to theatricality and "playing" within the play. The plot against Malvolio revolves around these ideas, and Fabian remarks in Act III, Scene iv: "If this were play'd upon a stage now, I could condemn it as an improbable fiction". In Act IV, Scene ii, Feste (The Fool) plays both parts in the "play" for Malvolio's benefit, alternating between adopting the voice of the local curate, Sir Topas, and his own voice. He finishes by likening himself to "the old Vice" of English Morality plays. Other influences of the English folk tradition can be seen in Feste's songs and dialogue, such as his final song in Act V. The last line of this song, "And we'll strive to please you every day", is a direct echo of similar lines from several English folk plays.
Twelfth Night or What You Will (to give the play its full title) was probably commissioned for performance as part of the Twelfth Night celebrations held by Queen Elizabeth I at Whitehall Palace on 6 January 1601 to mark the end of the embassy of the Italian diplomat, the Duke of Orsino.. It was again performed at Court on Easter Monday in 1618 and on Candlemas night in 1623.
The earliest public performance took place at Middle Temple Hall, one of the Inns of Court, on 2 February (Candlemas night) in 1602 recorded in an entry in the diary of the lawyer John Manningham, who wrote:
At our feast we had a play called "Twelve Night, or What You Will", much like "The Comedy of Errors" or "Menaechmi" in Plautus, but most like and near to that in Italian called "Inganni". A good practice in it to make the steward believe his lady-widow was in love with him, by counterfeiting a letter as from his lady, in general terms telling him what she liked best in him and prescribing his gesture in smiling, his apparel, etc. and then, when he came to practice, making him believe they took him for mad.
Clearly, Manningham enjoyed the Malvolio story most of all, and noted the play's similarity with Shakespeare's earlier play, as well as its relationship with one of its sources, the Inganni plays.
The play was also one of the earliest Shakespearean works acted at the start of the Restoration; Sir William Davenant's adaptation was staged in 1661, with Thomas Betterton in the role of Sir Toby Belch. Samuel Pepys thought it "a silly play", but saw it three times anyway during the period of his diary on 11 September 1661, 6 January 1663, and 20 January 1669. Another adaptation, Love Betray'd, or, The Agreeable Disappointment, was acted at Lincoln's Inn Fields in 1703.
After holding the stage only in the adaptations in the late 17th century and early 18th century, the original Shakespearean text of Twelfth Night was revived in 1741, in a production at Drury Lane. In 1820 an operatic version by Frederic Reynolds was staged, with music composed by Henry Bishop.
Lilian Baylis reopened the long-dormant Sadler's Wells Theatre in 1931 with a notable production of the play starring Ralph Richardson as Sir Toby and John Gielgud as Malvolio. The Old Vic Theatre was reopened in 1950 (after suffering severe damage in the London Blitz in 1941) with a memorable production starring Peggy Ashcroft as Viola. Gielgud directed a production at the Shakespeare Memorial Theatre with Laurence Olivier as Malvolio and Vivien Leigh playing both Viola and Sebastian in 1955. The longest running Broadway production by far was Margaret Webster's 1940 staging starring Maurice Evans as Malvolio and Helen Hayes as Viola. It ran for 129 performances, more than twice as long as any other Broadway production.
A memorable production directed by Liviu Ciulei at the Guthrie Theater in Minneapolis, October-November 1984, was set in the context of an archetypal circus world, emphasising its convivial, carnival tone.
When the play was first performed, all female parts were played by men or boys, but it has been the practice for some centuries now to cast women or girls in the female parts in all plays. The company of Shakespeare's Globe, London, has produced many notable, highly popular all-male performances, and a highlight of their 2002 season was Twelfth Night, with the Globe's artistic director Mark Rylance playing the part of Olivia. This season was preceded, in February, by a performance of the play by the same company at Middle Temple Hall, to celebrate the 400th anniversary of the play's première, at the same venue. The same production was revived in 2012-13 and transferred to sell-out runs in the West End and Broadway. Stephen Fry played Malvolio. It ran in repertory with Richard III.
Interpretations of the role of Viola have been given by many well-renowned actresses in the latter half of the 20th century, and have been interpreted in the light of how far they allow the audience to experience the transgressions of stereotypical gender roles. This has sometimes correlated with how far productions of the play go towards reaffirming a sense of unification, for example a 1947 production concentrated on showing a post-World War II community reuniting at the end of the play, led by a robust hero/heroine in Viola, played by Beatrix Lehmann, then 44 years old. The 1966 Royal Shakespeare Company production played on gender transgressions more obviously, with Diana Rigg as Viola showing much more physical attraction towards the duke than previously seen, and the court in general being a more physically demonstrative place, particularly between males.John Barton's 1969 production starred Donald Sinden as Malvolio and Judi Dench as Viola; their performances were highly acclaimed and the production as a whole was commented on as showing a dying society crumbling into decay.
Malvolio is a popular character choice among stage actors; others who have taken the part include Ian Holm many times, Simon Russell Beale (Donmar Warehouse, 2002), Richard Cordery in 2005, Patrick Stewart, in Chichester, in 2007, Derek Jacobi (Donmar Warehouse) in 2009, Richard Wilson in 2009 and Stephen Fry at the Globe in 2012.
In March 2017, the Royal National Theatre's production of Twelfth Night  changed some of the roles from male to female, including Feste, Fabian (which became Fabia), and most notably, Malvolio - which became Malvolia - played by Tamsin Greig to largely positive reviews. As a result, the production played with sexuality as well as gender.
Due to its themes such as young women seeking independence in a "man's world", "gender-bending" and "same-sex attraction" (albeit in a roundabout way), there have been a number of re-workings for the stage, particularly in musical theatre, among them Your Own Thing (1968), Music Is (1977), All Shook Up (2005), and Play On! (1997), the last two jukebox musicals featuring the music of Elvis Presley and Duke Ellington, respectively. Another adaptation is Illyria, by composer Pete Mills. Theatre Grottesco created a modern version of the play from the point of view of the servants working for Duke Orsino and Lady Olivia. The adaptation takes a much deeper look at the issues of classism, and society without leadership. In 1999, the play was adapted as Epiphany by the Takarazuka Revue, adding more overt commentary on the role of theatre and actors, as well as gender as applied to the stage (made more layered by the fact that all roles in this production were played by women).
There was a 1986 Australian film.
The 1996 film adapted and directed by Trevor Nunn and set in the 19th century, stars Imogen Stubbs as Viola, Helena Bonham Carter as Olivia and Toby Stephens as Duke Orsino. The film also features Mel Smith as Sir Toby, Richard E. Grant as Sir Andrew, Ben Kingsley as Feste, Imelda Staunton as Maria and Nigel Hawthorne as Malvolio. Much of the comic material was downplayed into straightforward drama, and the film received some criticism for this.
The 2006 film She's the Man modernises the story as a contemporary teenage comedy (as 10 Things I Hate About You did with The Taming of the Shrew). It is set in a prep school named Illyria and incorporates the names of the play's major characters. For example, Orsino, Duke of Illyria becomes simply Duke Orsino ("Duke" being his forename). The story was changed to revolve around the idea of soccer rivalry but the twisted character romance remained the same as the original. Viola, the main character, pretends to be her brother Sebastian, and a girl named Olivia falls in love with Viola as Sebastian. She also goes to a restaurant named "Cesario's". Two of Duke's Illyria soccer teammates are named Andrew and Toby. A nod is given to the omitted subplot by naming a briefly-onscreen tarantula Malvolio. Sebastian's ex-girlfriend Monique was given the surname Valentine, and the meddling Malcolm was given the surname Festes.
Shakespeare in Love contains several references to Twelfth Night. Near the end of the movie, Elizabeth I (Judi Dench) asks Shakespeare (Joseph Fiennes) to write a comedy for the Twelfth Night holiday. Shakespeare's love interest in the film, "Viola" (Gwyneth Paltrow), is the daughter of a wealthy merchant who disguises herself as a boy to become an actor; while Shakespeare, a financially struggling playwright suffering from writer's block, is trying to write Romeo and Juliet. She is presented in the final scene of the film as William Shakespeare's "true" inspiration for the heroine of Twelfth Night. In a nod to the shipwrecked opening of Shakespeare's Twelfth Night, the movie includes a scene where the character Viola, separated from her love by an arranged marriage and bound for the American colonies, survives a shipwreck and comes ashore to Virginia.
On 14 May 1937, the BBC Television Service in London broadcast a thirty-minute excerpt of the play, the first known instance of a work of Shakespeare being performed on television. Produced for the new medium by George More O'Ferrall, the production is also notable for having featured a young actress who would later go on to win an Academy Award - Greer Garson. As the performance was transmitted live from the BBC's studios at Alexandra Palace and the technology to record television programmes did not at the time exist, no visual record survives other than still photographs.
The entire play was produced for television in 1939, directed by Michel Saint-Denis and starring another future Oscar-winner, Peggy Ashcroft. The part of Sir Toby Belch was taken by a young George Devine.
In 1957, another adaptation of the play was presented by NBC on U.S. television's Hallmark Hall of Fame, with Maurice Evans recreating his performance as Malvolio. This was the first color version ever produced on TV. Dennis King, Rosemary Harris, and Frances Hyland co-starred.
In 1966 there was an Australian TV version.
Another version for UK television was produced in 1969, directed by John Sichel and John Dexter. The production featured Joan Plowright as Viola and Sebastian, Alec Guinness as Malvolio, Ralph Richardson as Sir Toby Belch and Tommy Steele as an unusually prominent Feste.
Yet another TV adaptation followed in 1980. This version was part of the BBC Television Shakespeare series and featured Felicity Kendal in the role of Viola, Sinéad Cusack as Olivia, Alec McCowen as Malvolio and Robert Hardy as Sir Toby Belch.
In 1998 the Lincoln Center Theater production directed by Nicholas Hytner was broadcast on PBS Live From Lincoln Center. It starred Helen Hunt as Viola, Paul Rudd as Orsino, Kyra Sedgwick as Olivia, Philip Bosco as Malvolio, Brian Murray as Sir Toby, Max Wright as Sir Andrew, and David Patrick Kelly as Feste.
A 2003 tele-movie adapted and directed by Tim Supple is set in the present day. It features David Troughton as Sir Toby, and is notable for its multi-ethnic cast including Parminder Nagra as Viola and Chiwetel Ejiofor as Orsino. Its portrayal of Viola and Sebastian's arrival in Illyria is reminiscent of news footage of asylum seekers.
An episode of the British series Skins, entitled Grace, featured the main characters playing Twelfth Night, with a love triangle between Franky, Liv and Matty, who respectively played Viola, Olivia and Orsino.
An adaptation of Twelfth Night by Cathleen Nesbitt for the BBC was the first complete Shakespeare play ever broadcast on British radio. This occurred on 28 May 1923, with Nesbitt as both Viola and Sebastian, and Gerald Lawrence as Orsino.
In 1937 an adaptation was performed on the CBS Radio Playhouse starring Orson Welles as Orsino and Tallulah Bankhead as Viola. A year later, Welles played Malvolio in a production with his Mercury Theater Company.
There have been several full adaptations on BBC Radio. A 1982 BBC Radio 4 broadcast featured Alec McCowen as Orsino, Wendy Murray as Viola, Norman Rodway as Sir Toby Belch, Andrew Sachs as Sir Andrew Aguecheek, and Bernard Hepton as Malvolio; in 1993, BBC Radio 3 broadcast a version of the play (set on a Caribbean Island), with Michael Maloney as Orsino, Eve Matheson as Viola, Iain Cuthbertson as Malvolio, and Joss Ackland as Sir Toby Belch; this adaptation was broadcast again on 6 January 2011 by BBC Radio 7 (now Radio 4 Extra). 1998 saw another Radio 3 adaptation, with Michael Maloney, again as Orsino, Josette Simon as Olivia and Nicky Henson as Feste. In April 2012, BBC Radio 3 broadcast a version directed by Sally Avens, with Paul Ready as Orsino, Naomi Frederick as Viola, David Tennant as Malvolio and Ron Cook as Sir Toby Belch.
In 1888, Alexander Campbell Mackenzie composed an overture based on Twelfth Night.
In 1942, Gerald Finzi set the songs "O Mistress Mine" (Act II, Scene 3) and "Come Away, Come Away, Death" (Act II, Scene 4) to music as part of his song cycle on Shakespearean texts Let Us Garlands Bring.
In 1943, Erich Korngold set the songs "Come Away, Death" (Act II, Scene 4), "O Mistress Mine" (Act II, Scene 3), "Adieu, Good Man Devil" (Act IV, Scene 2), "Hey, Robin" (Act IV, Scene 2), and "For the Rain, It Raineth Every Day" (Act V, Scene 1) as a song cycle entitled Narrenlieder, Op. 29.
Roger Quilter set "O Mistress Mine" and "Come Away, Come Away, Death" in his Three Shakespeare Songs, Op. 6.
Swedish composer Sven-Eric Johanson's song cycle for mixed chorus and piano "Fancies I" includes a setting in waltz time of "O Mistress Mine" (1974).
British composer Peter Racine Fricker set "O Mistress Mine" in 1961.
"O Mistress Mine" set by Peter Warlock, 1924.
The Danish philosopher Søren Kierkegaard opens his 1844 book Philosophical Fragments with the quote "Better well hanged than ill wed" which is a paraphrase of Feste's comment to Maria in Act 1, Scene 5: "Many a good hanging prevents a bad marriage". Nietzsche also refers passingly to Twelfth Night (specifically, to Sir Andrew Aguecheek's suspicion, expressed in Act 1, Scene 3, that his excessive intake of beef is having an inverse effect on his wit) in the third essay of his Genealogy of Morality.
Agatha Christie's 1940 mystery novel Sad Cypress draws its title from a song in Act II, Scene IV of Twelfth Night.
The protagonists of Vita Sackville-West's 1930 novel The Edwardians are named Sebastian and Viola, and are brother and sister. Victoria Glendinning comments, in her introduction to the novel: "Sebastian is the boy-heir that Vita would like to have been... Viola is very like the girl that Vita actually was." 
American playwright Ken Ludwig wrote a play inspired by the details of Twelfth Night, called Leading Ladies.
Two of the dogs in the film Hotel for Dogs are twins called Sebastian and Viola.
Elizabeth Hand's novella Illyria features a high school production of Twelfth Night, containing many references to the play, especially Feste's song.
One of Club Penguins plays, Twelfth Fish, is a spoof of Shakespeare's works. It is a story about a countess, a jester, and a bard who catch a fish that talks. As the play ends, they begin eating the fish. Many of the lines are parodies of Shakespeare.
Shakespeare, having tackled the theatrical problems of providing Twelfth Night with effective musical interludes, found his attitude toward his material changed. An episodic story became in his mind a thing of dreams and themes.