Photo: Mason Trinca / Special To The Chronicle Photo: Akiko I/Yelp Photo: ErikaC/Yelp Photo: Katie Wood Photo: Katie Wood Photo: Mason Trinca / Special To The Chronicle Buy this photo Photo: Daniel E. Porter / The Chronicle 2014 Photo: Paul Kuroda / Special To The Chronicle Photo: Chronicle Archives Photo: Jodi A/Yelp Photo: Adam S/Yelp Photo: Atsuko Morita Photo: Mike Kepka, The Chronicle Photo: Gabrielle Lurie / The Chronicle 2016 Photo: Scott Strazzante / The Chronicle Photo: Tracy A -- Yelp Photo: Bumble B/Yelp Photo: Liz Hafalia, The Chronicle Photo: Yue Wu, The Chronicle Photo: Michael Macor, The Chronicle Buy this photo Photo: Michael Macor, The Chronicle Photo: SG/Yelp Photo: Megan Farmer, The Chronicle Photo: Kiran U/Yelp Photo: Mason Trinca / Special To The Chronicle

The dive bar in San Francisco means far more than a cheap drink and a messy restroom – it brings a sense of community, identity, and history. And that bond shows every time one of the city’s beloved dives closes its doors due to rising costs, or changes so much to stay viable that it loses its grimy appeal.

Recent examples include the Tenderloin’s Hemlock Tavern, which closed in October to make way for condos. Lucky 13 is hanging on by a thread, but a permit for its demolition has been filed and it seems a matter of time before a developer tears it down for a 27-unit apartment building.

There are, however, San Francisco dive bars that are surviving and thriving decades after they first opened their doors. Look through our gallery above to plan a visit.

We should mention here that the term “dive bar” is open to interpretation, and for some it’s defined more by a feeling than any features. For our purposes we stuck to dive bars that have existed roughly 30 years or more, don’t practice mixology, aren’t dominated by dance music most nights, keep the lights low, haven’t overhauled their interior, and keep a diverse set of local regulars.

READ ALSO: Artist is photographing SF dive bars 'before they are gone'

We met local bartender Stellar Cassidy at Specs’ Twelve Adler Museum Café, which turned 50 this year, for her opinion on what makes a great dive bar, and she pointed to that last factor (see more of her comments in the video below).

“I also know a good bar when it has a mixed bag of people,” said Cassidy, who bartends at Church Key and City Beer Store. Bars that are maybe not so divey or newer tend to be homogenized or specialized on one thing like cocktails or food. But at Specs I can always count on people coming from all walks of life, all ages, all economic backgrounds.”

At least for now, the dives on this list won’t be going anywhere.