I am reading the Wikipedia articles on the titles of the King of Spain (this and this) and I am confused why they list countless places that are not under Spanish rule and or are totally defunct as a monarchy. The King of Hungary especially really caught my eye. How did the Spanish Crown come to claim that title anyway?
They're maintained as a matter of tradition, which is not unusual in monarchies. It's used both for prestige and as a relic of an era when European diplomacy revolved around territorial claims of the monarchs. That said, most titles do have clear geographical or dynastic sources. If you do find one that seems strange, leave a comment and I'll see if I can supply an explanation.
The title for Corsica was part of the Crown of Aragon, which formed a dynastic union with the Crown of Castile that later became Spain. In 1297 the Pope created a purely titular Regnum Sardiniae et Corsicae for James II of Aragon, even though neither controlled either Sardinia or Corsica. Nonetheless, the "kingdom" was inherited by the heirs and descendants of Isabela I and Ferdinand II, along with all the other titles the couple possessed.
For Hungary, the answer is simple: he doesn't.
With a little digging, it becomes apparent that the user Zeubea inserted the "the King of Hungary, Dalmatia, Croatia" etc titles into the Crown of Spain article. Since he didn't provide a source, all we have to go by is his other edits. Apparently, he believes Charles V obtained the Hungarian title somehow and passed it to his Spanish heirs. He added the claims to the Charles V article, stating at first that the titles were:
just nominally held by his son Philip II of Spain, honoring Castile and Aragon efforts against Otoman empire in Eastern Europe.
Awful English aside, logically, this doesn't really make any sense. It is well established that it was Charles V's brother, Ferdinand I, who was elected King of Hungary. Ferdinand's son Maximilian became King of Hungary after him. Why would it go to Philip II, his nephew?
A mere hour later Zeubea changed his story, claiming instead that:
Philip II of Spain held the King of Hungary, of Bohemia, and of Croatia title just nominally, inherited from his aunt Mary of Hungary [[Mary_of_Hungary_(governor_of_the_Netherlands)|Mary of Hungary]], sister of Charles V and widow of [[Louis_II_of_Hungary]], who inherited the title by testament of Charles V.
Broken syntax aside, once again this makes absolutely no sense whatsoever.
Mary of Hungary was Queen Consort of Hungary by virtue of her marriage to Louis II. How can Philip II inherit the title from someone who doesn't hold it in her own right?
How can Philip II inherit a title that's based on being married to the king? Was Philip II the wife of duly crowned, legal Hungarian King, his uncle Ferdinand I?
How does Mary "inherit" the title by "testament" of Charles V anyway, when she was Queen of Hungary long before Charles V died (in the same year as her)?
Zeubea did not cite any references in his article edits, but he leave an entry on the talk page asserting that:
Because of testament of Charles V, like a deference to his widow sister Mary of Hungary, he let her to use this title on life. Then, because of her marriage with Louis II of Hungary without (legal) descendents, these titles laid nominaly on Philip II of Spain, and, from him, Spanish Crown holds the King of Hungary, of Bohemia, and of Croatia nominal titles.
More terrible English aside, once again this makes no sense whatsoever. Louis II did die without issue, but how could Philip II inherit his title? The Hungarian crown was elective and the magnates of Hungary elected Ferdinand I. Even if the Crown of St Stephen was inheritable, it would've gone to Louis II's heir, not his wife's heir.
This time however, Zeubea did list a couple of links to ostensibly support his claims. Let's look at the first one. Hungary only seem to appear twice:
Doña María de Hungría, Gobernadora de los Países Bajos (1531 - 1555), no tenía sucesión.
Which just says Mary of Hungary had no issue. Okay.
María (1505), Reina de Hungría desde 1522, Gobernadora de los Países Bajos (1531 - 1555).
Which just says Mary was Queen of Hungary after 1522. Which makes sense since she married Louis of Hungary in 1522. Doesn't help either.
So Zeubea's first link actually proved himself wrong: Mary was Queen of Hungary by marriage, not from "the testament of Charles V". Maybe the second link would be more helpful. Once again Hungary only seem to appear twice:
Es verdad que si pudiese acabar con la reina viuda de Hungría, mi hermana, que continuase en el dicho cargo, que ha tanto tiempo tenido, sería lo que más convernía, porque ella lo ha hecho muy bien en paz y en guerra. Mas está puesta en descargarse de él; en fin, se determinará todo con vuestra venida, placiendo a Dios.
Which basically says that his sister Mary is the Queen Dowager of Hungary, and how she has been doing so well in her position that he doesn't want to let her stop. This was written in 1548. By then, Mary had been Governor of the Netherlands since 1531, a position she is known to resent and yet Charles V is known to have thought she handled well. Considering Mary hadn't been in Hungary for decades by that point, clearly this is saying that Mary should continue being Governor of the Netherlands - not about being "king of Hungary".
Well there's only one mention of Hungary left so this must be it!
Lo mismo siempre he hallado en la reina viuda de Francia y en la reina viuda de Hungría, mis hermanas, y tengo por cierto que entrambas y cada una continuará esta voluntad con vos, y ansí recíprocamente debéis corresponder, y tenedlas siempre por buenas tías, y favorecedlas siempre en todo lo que pudiéredes, y os ruego, y os lo encomiendo.
But... this is just talking about his sisters, the Queen Dowager of Hungary again (and the Queen Dowager of France, so Eleanor). Well that's a bust. The only reasonable explanation is that Zeubea was wrong, as his own sources proved. It seems he might have confused Charles V's comments on Mary's performance in the job of governing the Netherlands, for her honorific title as a former queen consort of Hungary. But either way he said nothing about giving Mary's position to Philip II.
tl:dr - Wikipedia is an unreliable source.
Charles V as King of Hungary
To be fair, Charles V may have claimed the throne of Hungary upon his election as Holy Roman Emperor. The website @MAGolding used is the only source that confirms this, but Charles could well have inherited the claim from Maximilian I, his grandfather. Maximilian's father, Charles's great grandfather Frederick III, was heir to Ladislaus the Posthumous, the last of the Albertine Habsburgs and a King of Hungary. He was a ward of Frederick during his youth, and his mother Queen Elizabeth had also entrusted the Emperor with the Holy Crown of Hungary.
After Ladislaus died, Frederick had himself crowned King of Hungary in 1459 and invaded Hungary, then under the control of Matthias Hunyadi. They made peace in 1463, with Frederick returning the Crown and recognising Matthias, but retaining his title and the promise that he would succeed Matthias to Hungary if he failed to produce a male heir. The Hungarians ended up setting the treaty aside and electing Vladius of Poland when Mathias died in 1490 without male issue, but the two sides subsequently signed another treaty stipulating pretty much the same terms, but with Maximilian succeeding Vladislaus if the latter produced no heir.
So it's quite plausible for Charles V, heir of Maximilian, to maintain his grandfather's claims on Hungary when he became emperor. But be that as it may, it's a moot point as far as the Crown of Spain is concerned. Again, it's clear that nothing in Charles V's testament left this particular title to his Spanish heir, Philip II. Moreover, the same website which confirmed Charles V was titular king of Hungary, also explicitly omitted the Hungarian title from the Spanish monarchs.
In any case, Ferdinand I finally achieved the family dream when he was elected king in 1526.
Naples's Link to Hungary
Actually, yes, but it is as tenuous as tenuous can be. In 1385, Charles III, King of Naples seized power in Hungary from Mary, and had himself elected King. He was promptly killed a couple of months later, but his son King Ladislaus of Naples took up this claim and made several attempts to become King of Hungary himself. He had basically zero success, but it started a tradition for his heirs.
Ladislaus died without issue in 1414. His sister Joanna succeeded him, and maintained the same titular claims to Hungary. She adopted Alfonso the Magnanimous in 1421, but repudiated it soon afterwards when they had a falling out, so that Renee was named the next king when she died in 1435, also without issue.
Alfonso was King of Aragon, but Naples didn't say with the Crown of Aragon because he died, also without legitimate issue, in 1458. The Crown of Aragon passed to his brother John the Great, but Alfonso's bastard son succeeded to the Kingdom of Naples as Ferdinand I. The titular claim to Hungary stayed with Naples, maintained by Ferdinand I. Shortly after he died in 1494 the French invaded and deposed his son, though.
King John, and his son Ferdinand II (the same one who married Isabel of Castile), didn't claim Hungary. But after the Neapolitan branch of the family was ousted, Ferdinand II conquered it back from the French in 1504. By then Aragon had been united with Castile. Naples thus passed into the United Spanish crown, through Joanna the Mad to Emperor Charles V in 1516, little more than a decade later. Note that, even though they were united under one ruler (or ruling couple), this "Spain" was still a disparate collection of very independent polities, each with their own traditions, laws, and customs.
Hence, documents issued by the Kingdom of Naples may use their (by then) traditional styles, which included Hungary. Equally, it makes sense for the Spanish Crown, having been united without Naples in 1474, to not mention Hungary, as @MAGolding apparently finds in his answer.
It's actually not that unusual for monarchs to claim titles in pretence as a means of increasing their prestige. The Kings of England and Great Britain had famously claimed to also be Kings/Queens of France right up until the Act of Union in 1800, despite the minor detail that England had lost Calais, her sole remaining possession on the European mainland, in 1598!
In this case, the Spanish Constitution of 1978 states that:
"[The King's] title is that of King of Spain, and he may use the other titles appertaining to the Crown".
- [article 56(2)] (my emphasis)
However, it doesn't trouble itself with defining what these "other titles" might be. It would therefore appear that the King can (if he so chooses) use any title that has previously been claimed by a Monarch of Spain, or ruler of the Spanish Empire.
Now, in practice, the last monarch that actually used the long title was Isabella II whose full title was:
"Isabel II by the Grace of God, Queen of Castile, Leon, Aragon, of the Two Sicilies, of Jerusalem, of Navarre, of Granada, of Toledo, of Valencia, of Galicia, of Majorca, of Seville, of Sardinia, of Córdoba, of Corsica, of Murcia, of Menorca, of Jaén, the Algarves, Algeciras, Gibraltar, the Canary Islands, of the East and West Indies, Islands and Mainland of the Ocean Sea; Archduchess of Austria; Duchess of Burgundy, Brabant, Milan and Aspurg; Countess of Flanders, Tirol and Barcelona; Lady of Biscay and Molina"
You'll see that list includes most of those in the original Wikipedia article, but there's no mention of Hungary. There's a reason for that, as we'll see shortly.
The claim that the Spanish crown can lay claim to be King of Hungary, even if only as a titles in pretence, appears (as with many of the claims of the current Spanish crown) to date back to Charles V, Holy Roman Emperor, whose full titulature apparently (according to Wikipedia) went as follows:
"Charles, by the grace of God, Holy Roman Emperor, forever August, King of Germany, King of Italy, King of all Spains, of Castile, Aragon, León, of Hungary, of Dalmatia, of Croatia, Navarra, Grenada, Toledo, Valencia, Galicia, Majorca, Sevilla, Cordova, Murcia, Jaén, Algarves, Algeciras, Gibraltar, the Canary Islands, King of Two Sicilies, of Sardinia, Corsica, King of Jerusalem, King of the Western and Eastern Indies, of the Islands and Mainland of the Ocean Sea, Archduke of Austria, Duke of Burgundy, Brabant, Lorraine, Styria, Carinthia, Carniola, Limburg, Luxembourg, Gelderland, Neopatria, Württemberg, Landgrave of Alsace, Prince of Swabia, Asturia and Catalonia, Count of Flanders, Habsburg, Tyrol, Gorizia, Barcelona, Artois, Burgundy Palatine, Hainaut, Holland, Seeland, Ferrette, Kyburg, Namur, Roussillon, Cerdagne, Drenthe, Zutphen, Margrave of the Holy Roman Empire, Burgau, Oristano and Gociano, Lord of Frisia, the Wendish March, Pordenone, Biscay, Molin, Salins, Tripoli and Mechelen".
Now, there is an interesting source for the claim to the crowns of Hungary, Dalmatia and Croatia.
From a talk on Wikipedia titled About King of Hungary, of Dalmatia, and of Croatia nominal titles attached to Spanish Crown (not Bohemia). Testament of Charles V we see the following:
Because of testament of Charles V, like a deference to his widow sister Mary of Hungary, he let her to use this title on life. Then, because of her marriage with Louis II of Hungary without (legal) descendents, these titles laid nominaly [sic] on Philip II of Spain, and, from him, Spanish Crown holds the King of Hungary, of Bohemia, and of Croatia nominal titles.
(NOTE: Sources in Spanish)
The testament (transcribed in the first source above) sets out a (slightly complicated) line of succession, based on who produced a legitimate heir. At the head of the list is his son, the future Philip II of Spain. The eventual heir was supposed to inherit:
"... our realms, estates and lordships ..."
Now, in practice, the testament was superseded by events. Charles was succeeded as Holy Roman Emperor by his brother, Ferdinand I. Ferdinand had also been elected as King of Hungary in 1527, following the regency of their sister Mary, and so was now both Holy Roman Emperor and King of Hungary.
So, did this mean that Ferdinand now inherited all of Charles V's "realms, estates and lordships", as set out in Charles' testament?
Well, no. In fact, Charles' son Philip actually inherited Spain, the Spanish Empire, Naples, Sicily, Milan, and the Netherlands.
So at no point was a king of Spain, or the Spanish Empire also the King of Hungary, and there seems to be no basis for the claim - even a claim for a title in pretence - to the Crown of Hungary.
Indeed, I've not been able to find any Spanish source since 1558, when Philip II ascended to the throne, that makes the claim.
So, to answer your question, most of the claims listed on those pages to titles in places where Spain no longer rules or which no longer exist rest on hereditary claims on the basis that those titles were previously held by either the ruler of Spain or the ruler of the Spanish Empire. Although they are titles in pretence, their use was nevertheless permitted under the Spanish Constitution of 1978.
For the rest, including the Hungarian Crown of St Stephen, there seems to be no evidence to support the assertion that the Kings of Spain have any claim to those titles (even a claim to a title in pretence).
(For more information about the life of Mary of Hungary, and the accession of Ferdinand to the throne of Hungary, Mary of Hungary: Second Regent of the Netherlands by Jane de Iongh is available to read or download on archive.org.)
Apparently the kings of the Spanish kingdoms never included "King of Hungary, Dalmatia, Croatia" among their titles in Spanish documents, but for centuries kings of the Spanish Kingdoms used the title of "King of Hungary, Dalmatia, Croatia" in official documents in one or more other realms that they ruled.
I don't know why a monarch would claim Kingdom A in his kingdoms of B and C but not in his Kingdoms of D and E, but that was the case. Of course the kings of Spain claimed so many royal titles it was hard to keep track of them, so maybe the title of "King of Hungary" was simply overlooked by the chanceries in some kingdoms.
The website Titles of European Hereditary Rulers lists many titles of the rulers of the various countries in Europe over the centuries.
According to the chapter on Spain, there doesn't seem to have been any Spanish monarch who listed the kingdom of Hungary among his titles in documents in Spain itself.
For example, Emperor Charles V never used King of Hungary among his titles in documents in his function as King of the Spanish kingdoms. His titles were:
King of Castile, Leon, Aragon, both Sicilies, Jerusalem, Navarra, Granada, Toledo, Valencia, Galicia, Majorca, Sevilla, Sardinia, Cordova, Corsica, Murcia, Jaen, the Algarves, Algeciras, Gibraltar, the Canary Islands, the Indias, the Islands & Mainland of the Ocean sea; Count of Barcelona; Lord of Biscay, Molina; Duke of Athens, Neopatria; Count of Roussillon, Cerdagne; Margrave of Oristano, Goceano; Archduke of Austria; Duke of Burgundy, Brabant; Count of Flanders, Tyrol;
Don Carlos por la divina clemencia Enperador senper Augusto rey de Alemayna, doña Joana su madre, y el mismo don Carlos por la gracia de Dios, reyes de Castilla, de Leon, de Aragon, de las dos Secilias, de Jherusalem, de Navarra, de Granada, de Toledo, de Valencia, de Galizia, de Mallorcas, de Sevilla, de Cerdeña, de Cordova, de Corcega, de Murcia de Jaen, de los Algarves, de Algezira, de Gibraltar, de las Yslas de Canaria, de las Yndias, Yslas e Tierra Firme del mar Oceano, condes de Barcelona, señores de Vizcaya e de Molina, duques de Atenas e de Neopatria, condes de Ruysellon e de Cerdeña, marqueses de Oristan e de Gociano, archiduques de Austria, duques de Vorgoña e de Bravante, condes de Flandes e de Tirol etc.
Most of the titles claimed were places Charles actually ruled, though the Kingdom of Corsica had never actually been ruled by Spanish monarchs and the Kingdom of Jerusalem and the Duchies of Athens and Neopatra had been conquered by the Turks.
But a monarch of different realms can use different titles in different realms.
According to the section on Austria, Emperor Charles V's titles as Archduke of Austria from 1519 to 1521 included "King of Hungary", even though at that time Louis II was the king of Hungary, Bohemia, Dalmatia, Croatia, Rama, Serbia, Galicia, Lodomeria, Cumania, and Bulgaria.
King of Castilia, Aragon, Leon, both Sicilies, Jerusalem, Hungary, Dalmatia, Croatia, Navarra, Grenada, Toledo, Valencia, Galicia, Majorca, Sevilla, Sardinia, Cordova, Corsica, Murcia, Jaen, the Algarves, Algeciras, Gibraltar, the Canary Islands, the Islands of Indies, Mainland of the Ocean sea; Archduke of Austria; Duke of Burgundy, Lotharingia, Brabant, Styria, Carinthia, Carniola, Limburg, Luxembourg, Gelderland, Calabria, Württemberg, Athens, Neopatria; Count of Flanders, Habsburg, Tyrol, Gorizia, Barcelona, Artois, Burgundy Palatine, Hainaut, Holland, Seeland, Ferrette, Kyburg, Namur, Roussillon, Cerdagne, Zutphen, Landgrave of Alsace; Margrave of Burgau, Oristano, Gociano, the Holy Roman Empire; Prince of Swabia, Asturia, Catalonia; Lord of Frisia, the Wendish March, Pordenone, Biscay, Molin, Salins, Tripoli, Mechelen;
Wir Karl der funfft von gotts gnaden erweiter romischer keyser, zu allenn tzeitten merer des reichs etc. kunig in Germanien, zu Castilien, zu Arragon, zu Legion, beider Sicilien, zu Hierusalem, zu Hungern, zu Dalmacien, zu Croacien, zu Nauarra, zu Granaten, zu Toleten, zu Valentz, zu Galicien, Majoricarum, zu Hispalis, Sardinie, Cordubie, Corsice, Murcie, Giennis, Algarbien, Algecire, zu Gibraltaris vnd der insulen Canarie, auch der insulen Indiarum, vnd terre firme des mers Oceani etc. ertzhertzog zu Osterreich, hertzog zu Burgundi, zu Lotterigkh, zu Brabanndt, zu Steyr, Kerndten, Crain, Lymburg, Lutzemburg, Gheldern, Wirtemberg, Calabrien, Athenarum, Neopatrie etc. graue zu Flanndern, zu Habspurg, zu Tirol, zu Gortz, Parsiloni, zu Arthois vnd Burgundi etc. phaltzgraue, zu Henigeu, zu Hollandt, zu Seelandt, zu Phirt, zu Kiburg, zu Namur, zu Rossilion, zu Territan vnd zu Zutphen, lanndtgraue in Elsass, marggraue zu Oristani, zu Gotziani vnd des heiligen romischen reichs, fürst zu Swaben, zu Cathalonia, Asturia, etc. herr in Frieslanndt, auf der Windischen marckh, zu Portenaw, zu Biscaia, zu Molin, zu Salins, zu Trippoli vnd zu Mecheln etc.
Charles V claimed the title of King of Hungary, despite Louis II actually ruling in Hungary, as the heir of his grandfather Emperor Maximilian I and his great grandfather Emperor Frederick III. Frederick III claimed the throne of Hungary beginning in 1459. Nobles opposed to King Matthias elected Frederick King of Hungary in 1459.
King of Hungary, Dalmatia, Croatia; Duke of Austria, Styria, Carinthia, Carniola; Lord of the Wendish March, Pordenone; Count of Habsburg, Tyrol, Ferrette, Kyburg; Margrave of Burgau; Landgrave of Alsace;
Wir Friderich von gots gnaden Romischer kaiser, zu allen zeiten merer des reichs, in Hungarn, Dalmatien, Croatien etc. kunig, herzog zu Osterreich, zu Steir, zu Kernden und ze Krain, herr auf der Windischen March und zu Portenau, grave zu Habspurg, zu Tirol, zu Phirt und zu Kiburg, markgrave zu Burgau und lantgrave in Elsass
In 1521 Emperor Charles V gave the Archduchy of Austria and other Austrian lands to his younger brother Ferdinand I. Ferdinand I did not used the title of "King of Hungary" since his older brother Emperor Charles V was the heir to the family's hereditary claim to the Hungarian throne.
Then King Louis II of Hungary, Bohemia, Dalmatia, Croatia, Rama, Serbia, Galicia, Lodomeria, Cumania, and Bulgaria was killed at the Battle of Mohacs on 29 August 1526. Ferdinand I of Austria, married to Louis's sister Anne Jagellion, claimed the thrones of Hungary and Bohemia and was elected King separately in both kingdoms.
So naturally Ferdinand added "King of Hungary, Bohemia, Dalmatia, Croatia, Rama, Serbia, Galicia, Lodomeria, Cumania, and Bulgaria" to his titles in 1526.
King of Hungary, Bohemia, Dalmatia, Croatia, Slavonia; Archduke of Austria; Duke of Burgundy, Brabant, Styria, Carinthia, Carniola, Silesia, Luxemburg, Württemberg; Prince of Swabia; Margrave of the Holy Roman Empire, Moravia, above the Enns, Burgau, Lusatia; Princely Count of Habsburg, Tyrol, Ferrette, Kyburg, Gorizia; Landgrave of Alsace; Lord of the Wendish March, Pordenone, Salins;
Wir Ferdinand von Gottes Gnaden zu Hungarn, Böhmen, Dalmatien, Croatien, und Sclavonien &c. König, Infant zu Hispanien, Erz-Hertzog zu Oesterreich, Hertzog zu Burgundi, zu Braband, zu Steyer, zu Cärndten, zu Crain, zu Schlesien, zu Lützelburg, und zu Würtemberg, Fürst zu Schwaben, gefürsteter Graff zu [Habspurg,] zu Tyrol, zu Görtz, zu Pfird, zu Kyburg, Landgraff in Elsaß, Marggraff des Heilligen Römischen Reichs, zu Mähren, ob der Ens, zu Burggau, und zu Lausitz, Herr auf der Windischen Marck, zu Portenau und zu Salins, &c.
Emperor Charles V continued to use the title of "King of Hungary" in his documents as Emperor after 1521 and after 1526, until abdicating as Emperor in 1556, even though his brother Ferdinand I also used the title "King of Hungary after 1526.
Emperor of the Romans; King in Germany, of Castilia, Aragon, Leon, both Sicilies, Jerusalem, Hungary, Dalmatia, Croatia, Navarra, Grenada, Toledo, Valencia, Galicia, Majorca, Sevilla, Sardinia, Cordova, Corsica, Murcia, Jaen, the Algarves, Algeciras, Gibraltar, the Islands of Canary , of the Indies, Mainland of the Ocean sea; Archduke of Austria; Duke of Burgundy, Brabant, Lotharingia, Styria, Carinthia, Carniola, Limburg, Luxembourg, Gelderland, Athens, Neopatria, Württemberg; Landgrave of Alsace; Prince of Swabia, Asturia, Catalonia; Count of Flanders, Habsburg, Tyrol, Gorizia, Barcelona, Artois, Burgundy Palatine, Hainaut, Holland, Seeland, Ferrette, Kyburg, Namur, Roussillon, Cerdagne, Zutphen, Margrave of Burgau, Oristano, Gociano, the Holy Roman Empire; Lord of Frisia, the Wendish March, Pordenone, Biscay, Molin, Salins, Tripoli, Mechelen;
Wir Carl der Fünfft, von Gottes Gnaden, Römischer Kaiser, zu allen Zeiten Mehrer des Reichs, in Germanien, zu Castilien, Arragon, Leon, beeder Sicilien, Hierusalem, Hungarn,Dalmatien, Croatien, Nauarra, Granaten, Tolleten, Vallenz, Gallicien, Majorica, Hispalis, Sardinien, Corduba, Corsica, Murcien, Giennis, Algarbien, Algestrien, Gibraltar, der Canarischen und Indianischen Inseln und Terrefirme, des Oceanischen Meers &c. Künig, Ertz Herzog zu Oesterreich, Herzog zu Burgundi, zu Loterick, zu Braband, zu Steir, zu Kerndten, zu Crain, zu Lymburg, zu Limburg, zu Geldern, zu Calabrien, zu Athen, zu Neopatrien und Würtemberg &c. Grave zu Habspurg, zu Flandern, zu Tyrol, zu Gerts, zu Barenien, zu Arthois, und zu Burgundi &c. Pfalz.Grave, zu Henigau, zu Holland, zu Seeland, zu Pfurt, zu Kyburg, zu Namur, zu Rosilien, zu Teritania, und zu Zitphen &c. Landgrave im Elsäß, Marggraue zu Burgau, Oristein, zu Goziani, und des Heiligen Romischen Reichs, Fürst zu Schwaben, Catalonia, Asturia &c. Herr zu Frießland, auf der Windischen Marck, zu Portenau, Biscaien, zu Salines, zu Mölln, zu Tripoli und Mecheln &c.
When Charles V abdicated from his various realms, his brother Ferdinand I, ruler of Austria, Hungary, and Bohemia, became Emperor, having been elected King of The Romans decades earlier. Charles V's son Philip II inherited the Spanish thrones. Ferdinand and his descendants continued to use the title of "King of Hungary" since they continued to be kings of Hungary.
As I have already said, Philip II and his descendants never seem to have used the title of "King of Hungary" in Spanish documents even though Philip II was the heir of Emperor Frederick III's hereditary claim to the crown of Hungary.
Neither Charles V, Philip II, nor their successors claimed the Kingdom of Hungary in their titles as rulers of the Netherlands.
But the Kings of Spain used the title of King of Hungary from 1556 to 1711 in their titles as Kings of Sicily and Naples.
Nos Philippus Dei gratia Rex Castelle, Aragonum, Legionis, utriusque Siciliae, Hierusalem, Portugallie, Ungarie, Dalmatie, Croatie, Navarre, Granate, Toleti, Galletie, Mayoricarum, Hispalis, Sardinie, Cordube, Corsice, Murtie, Giennis, Algarbii, Algezire, Gibraltharis, Insulanim Canarie, nee non Indiarum orientalium et occidentalium, Insularum ac terre firme maris Oceani, Archidux Austrie, Dux Burgundie, Brabantie, Mediolani, Athenarum et Neopatrie, Comes Abspurgii, Flandrie, Tyrolis, Barchinone, Rossilionis, et Ceritanie,
The Naples government's use of the title of "King of Hungary, Dalmatia, Croatia" began in 1519, when the King of Naples (future Emperor Charles V) inherited his grandfather Maximilian I's lands and claims, including the claim to be "King of Hungary, Croatia, Dalmatia".
-  the Romans, Germany, Hungary, Dalmatia, Croatia In 1519, King Charles (+1558), inherited the possessions and claims of the House of Austria, after the death of his grandfather Emperor Maximilian I (1519). Notes:
- The House of Austria had claimed the Crown of Hungary since 1459, when the Hungarian nobles opposed to their King Matthias "the Corvinus" elected Emperor Frederick III, Maximilian's father, King of Hungary.
- The Crown of Hungary included the Kingdoms of Hungary, Dalmatia, Croatia, Dalmatia, etc.
- In 1519, the Princes-Electors of the Holy Roman Empire elected King Charles (+1558) as Emperor of the Romans and King of Germany (Charles V).
Why the chanceries in the Netherlands and in Spain didn't also adopt that title is unknown. It is possible that "King of Hungary" was omitted from the list of titles by mistake and never corrected in centuries.
Confusingly, previous kings of Naples had claimed the Hungarian crown since 1385. The kings of Naples used different combinations of the kingdoms claimed by the Hungarian monarchy at different times, sometimes merely Hungary, sometimes Hungary, Dalmatia, Croatia, Rama, Serbia, Galicia, Lodomeria, Cumania and Bulgaria.
The Kings of Naples stopped using "King of Hungary" in their titles in 1476 when King Ferdinand's daughter married King Matthias of Hungary, presumably as a result of the marriage negotiations.
- Hungary Notes: In Dec 1476, Beatrice (+1508), a daughter of King Ferdinand I, married Matthias "Corvinus" of Hunyad, King of Hungary.
Perhaps the fact that previous Kings of Naples had claimed the throne of Hungary influenced the government in Naples to add Charles V's Hungarian claim to the lists of titles while other chanceries in other lands he ruled did not.