King Malcolm III Canmore (died 1093) built his castle at Edinburgh, and his wife Queen (Saint) Margaret built a chapel within its walls - now the oldest building in the city. Her son, David I built the Abbey at Holyrood, a mile to the East along "The Royal Mile". Castle and Abbey became the anchor points of Edinburgh; a thriving town grew up along side the road between them along the ridge of the rocky outcrop.
During the Wars of Independence Edinburgh Castle was captured by the English until Robert the Bruce's nephew recaptured it by climbing its steep and craggy sides in the dead of night. Robert the Bruce granted Edinburgh a Royal Charter in 1329. By the end of the 1500's it was established as the Capital of Scotland, and growing in population. The inhabitants chose to build high houses close to the protection of the Castle. This resulted in high tennement buildings (some reached 14 storeys) most of which can be seen to this day in the Old Town.
When King James VI inherited the throne of England in 1603, Edinburgh ceased to be the principal site of the royal court, although it did continue to have its own Parliament. After the Act of Union in 1707, Parliament ceased to be held in Edinburgh. The loch below the North side of the castle was filled in and work began on what is known as the New Town. The loch had become very unsanitary due to the refuse that was deposited there by the inhabitants of the Old Town. New streets and and thousands of houses were planned and built in the Classical fashion around squares and a grid system of streets.
During the Victorian era, the New Town continued to grow, but the Old Town tenements around the Royal Mile declined into slums where poor people lived in cramped and insanitary conditions. Industry flourished in Glasgow, but Edinburgh remained the preserve of professionals, which it has tended to remain to this day. Nowadays Edinburgh has a thriving tourism industry and is home to a new Scottish Parliament.
