Handkerchief code
Handkerchief code or hanky code (also known as bandana code and 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 color-coded handkerchiefs (bandanas), usually in the back pocket. The hanky code was widely used in the 1970s as a "secret" gay code that was intended to go unnoticed by non-gays, but general awareness of the code has gone increasingly mainstream.
There is no universally-recognized, "official" color code, and regional variants of the code exist. However, there is widespread consensus on the meanings of a handful of colors, based on decades of precedent in the gay communities of many different countries -- such as yellow for watersports; red for fisting; and black for SM. Also, generally speaking, it is understood that a hanky displayed in the left-side pocket signifies a preference for taking the "top" or "dominant" or "Master" role, while the right side represents the "bottom" or "submissive" or "slave" role.
Today the bandanas are worn almost exclusively in the rear trouser pocket, on the left side of the body for tops and on the right for bottoms, just as tops wear their keys on the left belt loop and bottoms on the right. In the past bandanas were also worn tied around the neck (with the knot positioned on either the left or right side); around the ankle (when wearing boots or when undressed); hung from the left or right side of the belt, or on other parts of the body.
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 wherein 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). It is believed by some that the modern Hanky Code started in New York City in about 1970 when a journalist for the Village Voice joked that instead of simply wearing keys to indicate whether someone was a "top" or a "bottom", it would be more efficient to subtly announce their particular sexual focus by wearing different colored hankies
Examples
Color Meaning Practice
Color Meaning Practice 
| Black |
SM |
Indicates the wearer's interest in hardcore SM play, especially whipping. |
| Red |
Anal fisting |
Left pocket: Insertive partner. Right pocket: Receptive partner. |
| Yellow |
Watersports |
Urinating on (left), or being urinated upon by (right), another person |
| Grey |
Bondage |
Play involving ropes, handcuffs, or other restraints that limit the bottom's ability to move. |
| White |
Mutual masturbation |
| Light blue |
Oral sex |
Wearing it in the left back pocket or on the left side indicates willingness to receive fellatio. Wearing it in the right back pocket or on the right side indicates desire to perform fellatio. |
| Navy Blue |
Anal sex |
Wearing it in the left back pocket or on the left side indicates a preference to be the insertive partner (the "top" or "pitcher") during anal intercourse. Wearing it in the right back pocket or on the right side indicates a preference to be in the receptive role (the "bottom" or "catcher"). |
| Pink (Light Pink) |
Dildos |
| Charcoal |
Latex, PVC, or Rubber Fetish |
|
| Medium Blue |
Uniform fetish |
Police uniforms or uniforms worn by other authority figures |
| Teal |
Cock and ball torture |
| Khaki |
Military Sex (Uniform fetish) |
Likes wearing military uniforms |
| Olive drab |
Military person |
Left: A military top; Right: a military bottom |
| Kelly green |
sex for money |
Left: a male prostitute; right: a john (someone looking for a prostitute) |
| Hunter green |
Daddy/boy sex |
Looking for a boy (left) or looking for a daddy (right) |
| Brown |
Scat |
| Burnt umber |
Extreme sex |
Extreme sex such as branding; or sex that is taboo even among most people in the leather subculture, e.g. , pederasty or bestiality. |
| Orange |
Few limits |
When worn on the left, orange indicates that the wearer will top in relatively any fetish, anytime, anywhere. Conversely, when orange is worn on the right, it indicates the wearer will bottom in relatively any fetish, anytime, anywhere. |
| Robin Egg Blue (Pale Robin Egg Blue) |
69 |
| Aqua (Printer's Cyan) |
Aquaphilia |
Having sex in water, such as in a bathtub, shower or swimming pool |
| Lime |
Sitophilia |
Eating food off someone's body or having food eaten off one's body |
| Chamois |
Motorcycle sex |
Indicates the wearer is looking for sex involving a motorcycle as a prop, or involving one or more bikers in the sexual activities. |
| Mauve |
Navel fetish |
| Dark Pink |
Tit torture |
| Magenta (Printer’s Magenta) |
Armpits |
Left: likes armpits licked; right: likes to lick armpits |
| Fuchsia |
Spanking |
| Purple (HTML/CSS color) |
Piercings |
Actually piercing someone (left) or actually being pierced by someone (right) as an erotic stimulation; or one who has piercings (left) or one who desires someone with piercings (right) |
| Lavender (Bright Lavender) |
Cross dressing / Gender play |
| Mustard (Gold Ochre) |
Size queen |
|
| Gold (Golden) |
Menage-a-trois |
Two looking for one (left) or one looking for two (right) |
| Apricot |
Chubby chaser |
| Peach |
Bear or cub who is interested in sex with another bear or cub |
| Light yellow |
Spittting |
Left—wants to spit on partner during sex; right—wants to be spat upon during sex |
| Beige (Desert Sand) |
Rimming |
Anal-oral contact |
| Rust |
Ponyism |
| Camouflage |
Rugged outdoorsman |
Having sex outdoors in the country (such as when going camping) |
| Gingham |
Urban outdoorsman |
Having sex in city parks |
| Argyle |
Geeks |
A geek or nerd (left) or interested in geeks or nerds (right) |
| Doily (an actual doily, not a bandana with a doily pattern) |
Tearoom trade |
Likes to have sex in public lavatories |
| Gold (metallic gold) lamé |
Muscle sex |
Looking for sex with bodybuilders |
| Silver (metallic silver) lamé |
Starfucker |
Looking for a rock star or male groupie |
| Black leather bandana |
Leather fetish |
| Black velvet bandana |
Videotaping |
Likes to make videotapes of the act while having sex (left); likes to be videotaped (right) |
| Gray flannel bandana |
Suit and tie fetish |
Left--Likes to have sex while wearing a suit and tie; right--likes to have sex with someone who is wearing a suit and tie. |
| Houndstooth |
Biting |
Likes to bite (Left) or likes to be bitten (right) |
| Black and white checkerboard pattern |
Safe sex |
e.g., frottage, or mutual masturbation or striptease in front of mirrors |
|