Handkerchief code

The handkerchief code, also known as the hanky code, bandana code, or flagging, is a way of indicating, usually among gay male casual sex seekers or BDSM practitioners in the leather subculture in the United States, Canada and Europe, whether they are a top or bottom, and what kind of sex they are seeking, by wearing cotton color-coded handkerchiefs (bandanas), usually in the back pocket. This code was widely used in the 1970s, but is much less used today. (The terms bandana code, hanky code, or flagging are much more widely used among those in the leather subculture than the term handkerchief code.) It should be noted that this code has come into more general usage today. Therefore, while flagging a particular fetish/color is accepted as a valid indication of a fetishist's interests, it is not necessarily an indication that the wearer is a member of the leather subculture.

Origin
The wearing of various colored bandanas around the neck was common in the mid- and late-nineteenth century among cowboys, steam railroad engineers, and miners in the Western United States. It is thought that the wearing of bandanas by gay men originated in San Francisco after the Gold Rush, when, because of a shortage of women, men dancing with each other in square dances developed a code where the man wearing the blue bandana took the male part in the square dance, and the man wearing the red bandana took the female part (these bandanas were usually worn around the arm or hanging from the belt or in the back pocket of one's jeans).

The modern-day version of this bandana code actually dates from the '70s when the New York City newspaper, The Village Voice, published an article suggesting that it would be easier for gay men in Greenwich Village to pick each other up if they didn't only have to rely on wearing their keys in their back pockets, left to denote active, right passive. The story suggested that they should all get down to the surplus store at the intersection of Christopher and Washington Streets where they could buy color-coded Levi's bandanas.

Although it was originally said in a sarcastic manner, the gay community took the recommendation to heart, not only in New York, but eventually across the globe. Although the code isn't as strong as it once was, it still exists in some circles.

How the bandanas are worn
The bandanas are worn on the left side of the body for tops and the right for bottoms. Today, they are almost exclusively worn (or "flagged") in the rear jeans pocket, just as tops wear their keys on the left belt loop and bottoms on the right. In the 1970s it was very common for men to wear their hanky tied around their neck (with the knot positioned on either the left or right side), or around the ankle, especially when wearing boots, or, when undressed. The bandanas have been worn hanging from the left or right side of one's belt. A go-go dancer at a gay club may wear the bandanas around the right or left side of his g-string to indicate what kind of sex he is interested in if he meets someone after his performance.

There is no universally understood color code, and there have been some regional variations. There is general agreement upon the colours for more common practices, particularly those with an intuitive relation between the color and the practice (e.g.: yellow for watersports, brown for scat, black for SM, orange for very advanced, very kinky, green for sex for money), but there is no absolute consensus for the more uncommon practices (those appearing toward the bottom of the list, or unlisted). The colours shown below represent a more or less common consensus.

The bandana code in pop culture

 * Peaches, the German-Canadian electroclash musician, has a song called "Hanky Code" in which she spells out the hanky code's various colors and their meanings.