The origin of the current flag of Spain is the naval ensign of 1783, Pabellón de la Marina de Guerra under Charles III of Spain.
The flag of Spain (Spanish: La Bandera de España), as it is defined in the Spanish Constitution of 1978, consists of three horizontal stripes: red, yellow and red, the yellow stripe being twice the size of each red stripe. Traditionally, the middle stripe was defined by the more archaic term of gualda, and hence the popular namerojigualda (red-weld).
The Spanish flag was chosen by Charles III himself among 12 different flags designed by Antonio Valdés y Bazán (all projected flags were presented in a drawing which is in the Naval Museum of Madrid). The flag remained marine for much of the next 50 years, flying over coastal fortresses, marine barracks and other naval property. During the Peninsular War the flag could also be found on marine regiments fighting inland. Not until 1820 was the first Spanish land unit (The La Princesa Regiment) provided with one and it was not until 1843 that Queen Isabella II of Spain would make the flag official.
Throughout the 18th, 19th, and 20th centuries, the color scheme of the flag remained intact, with the exception of the Second Republic period (1931–1939); the only changes centered on the coat of arms. Wikipedia