The town is situated in Sundgau between the towns of Mulhouse (approximately 27 km north) and Belfort (approximately 23 km west) and lies on the river Largue, a tributary of the Ill (a river which flows into the Rhein).
In 1016 the town is mentioned as Danamarachiricha meaning "Church of the Lady Mary".
Throughout history the name changed several times and took on some French and German forms.
Until the end of the Thirty Years' War in 1648 it was ruled over by the House of Habsburg before falling under the jurisdiction of Cardinal Mazarin.
In August 1914, during the First World War, French troops moved in during the fighting on the approaching Western Front and it became the military headquarters.