Zürich was an independent (reichsfrei) city or city-state from 1218 to 1798. The town was fortified with a city wall from the 13th to the 17th century, and with more elaborate ramparts constructed in the 17th to 18th century and mostly demolished in the 1830s to 1870s.