St. Margaret's chapel was built in the 12th century, in honor of Queen Margaret by her son David I. It is situated in the upper ward of the castle, and is the oldest surviving building in Edinburgh. The Romanesque chapel is very small, with many stained glass windows and historical artefacts within. Queen Margaret herself died within the castle shortly after hearing the news that her husband King Malcolm III had died in battle.