structural:expansion, information:highlighting
19th century

As a result of British fears that Denmark would ally with France, a Royal Navy fleet under the command of Admiral Sir Hyde Parker was dispatched to neutralize the Royal Dano-Norwegian Navy. On 2 April 1801, Parker's fleet encountered the Dano-Norwegian navy anchored near Copenhagen. Vice-Admiral Horatio Nelson led the main attack. The Dano-Norwegian fleet put up heavy resistance, and the battle is often considered to be Nelson's hardest-fought battle, surpassing even the heavy fighting at Trafalgar. It was during this battle that Lord Nelson was said to have "put the telescope to the blind eye" in order not to see Admiral Parker's signal to cease fire. The British ultimately won the battle, sinking or capturing most of Dano-Norwegian fleet, which led Denmark to agree not to ally with France.

In 1807, as a result of continued British fears that Denmark would ally with France, another British fleet led by Admiral James Gambier was dispatched to Copenhagen with orders to seize or destroy the Dano-Norwegian navy. The British published a proclamation demanding the surrender of the Dano-Norwegian fleet, and the Danish responded with "what amounted to a declaration of war". Gambier's forces responded by carrying out a naval bombardment of Copenhagen from 2 to 5 September. The bombardment, which saw the deployment of Congreve rockets, killed 195 civilians and wounded 768, along with burning approximately 1,000 structures, including the Church of Our Lady. Copenhagen's defenders were unable to respond to the bombardment effectively due to relying on an old defence-line whose limited range could not reach the British ships and their longer-range artillery. A British landing force of 30,000 men entered and occupied Copenhagen; during the battle, the British suffered almost 200 casualties, while the Danish suffered 3,000. Virtually the entire Dano-Norwegian fleet was surrendered to the British, who either burnt them or brought them back to Britain. Denmark declared war on Britain, leading to the outbreak of the Gunboat War, which lasted until the 1814 Treaty of Kiel.

Despite the turmoil the Napoleonic Wars brought to the city, Copenhagen soon experienced a period of intense cultural creativity known as the Danish Golden Age. Painting prospered under C.W. Eckersberg and his students while C.F. Hansen and Gottlieb Bindesbøll brought a Neoclassical look to the city's architecture. In the early 1850s, the ramparts of the city were opened to allow new housing to be built around The Lakes (Danish: Søerne) that bordered the old defences to the west. By the 1880s, the districts of Nørrebro and Vesterbro developed to accommodate those who came from the provinces to participate in the city's industrialization. This dramatic increase of space was long overdue, as not only were the old ramparts out of date as a defence system but bad sanitation in the old city had to be overcome. From 1886, the west rampart (Vestvolden) was flattened, allowing major extensions to the harbour leading to the establishment of the Freeport of Copenhagen 1892–94. Electricity came in 1892 with electric trams in 1897. The spread of housing to areas outside the old ramparts brought about a huge increase in the population. In 1840, Copenhagen was inhabited by approximately 120,000 people. By 1901, it had some 400,000 inhabitants.