The Habsburgs became rulers of Austria proper in 1278 and by the mid-14th century had come into possession of almost all the territory of present-day Austria (the principle exception being the Archbishophric of Salzburg). Maximilian I married Mary of Burgundy, the heiress to the territories of Charles the Bold, and thus the Habsburgs gained the entire Burgundian inheritance (with the exception of Burgundy itself, which France annexed), which included the Franche-Comte and most of the Low Countries. His son, Philip, married Juana who was the daughter and only child of Isabella of Castile and Ferdinand of Aragon (who outside of Iberia, ruled Sardinia and Sicily). Their son, Charles V, thus united four large dynastic inheritances in one person. He gained control of the remainder of the Low Countries during his reign as well as gaining Naples and Milan in the Italian wars against France. However, he ultimately left the Austrian inheritance to his younger brother Ferdinand and the rest to his son, Philip II. Following the Austrian Habsburgs, Ferdinand had been allowed to rule in Austria already in 1521 although it was not until 1556 that Charles V abdicated his title as Holy Roman Emperor, allowing Ferdinand to claim it. In 1526, Ferdinand was elected King of Bohemia (which also brought him Moravia and Silesia) and he was crowned King of Hungary the following year, although he ultimately only gained about 30% of Hungary, with the Ottomans controlling the rest. In the late 17th-century, the Habsburgs conquered the rest of the medieval Kingdom of Hungary from the Ottoman Empire (Treaty of Karlowitz, 1699). In the War of the Spanish Succession (1701-14), although Spain remained under the control of a Bourbon dynasty, the Austrian Habsburgs gained the Spanish Netherlands (Belgium and Luxemburg) and Spain's Italian possessions (Lombardy, Naples, and Sicily). In the War of the Austrian Succession, the Habsburgs lost Silesia to Prussia. Also in the 18th century, they lost control of the Kingdom of Naples (Naples and Sicily), but gained the Grand Duchy of Tuscany. As a result of the Napoleonic wars, they ultimately gave up the Austrian Netherlands to the (Dutch) Netherlands and no longer had direct control of Tuscany, but now ruled Venetia in addition to Lombardy and had annexed Salzburg during the wars. In 1859, they lost Lombardy in a war against France and Piedmont. In 1866, they lost the Seven Weeks' War to Prussia and Italy, resulting in the loss of Venetia. In 1918, following the collapse of the regime, the Habsburgs were denied their right to rule in most of their former territories, although Hungary technically remained a Kingdom without a king.