A flag is a piece of fabric (most often rectangular or quadrilateral) with a distinctive design and colors. It is used as a symbol, a signaling device, or for decoration. The term flag is also used to refer to the graphic design employed, and flags have evolved into a general tool for rudimentary signalling and identification, especially in environments where communication is challenging (such as the maritime environment, where semaphore is used). The study of flags is known as "vexillology" from the Latin vexillum, meaning "flag" or "banner".
National flags are patriotic symbols with widely varied interpretations that often include strong military associations because of their original and ongoing use for that purpose. Flags are also used in messaging, advertising, or for decorative purposes.
Some military units are called "flags" after their use of flags. A flag (Arabic: لواء) is equivalent to a brigade in Arab countries. In Spain, a flag (Spanish: bandera) is a battalion-equivalent in the Spanish Legion.
In antiquity, field signs or standards were used in warfare that can be categorized as vexilloid or 'flag-like'. Examples include the Sassanidbattle standard Derafsh Kaviani, and the standards of the Roman legions such as the eagle of Augustus Caesar's Xth legion, or the dragon standard of the Sarmatians; the latter was let fly freely in the wind, carried by a horseman, but judging from depictions it was more similar to an elongated dragon kite than to a simple flag.
During the High Middle Ages, flags came to be used primarily as a heraldic device in battle, allowing more easily to identify a knight than only from the heraldic device painted on the shield. Already during the high medieval period, and increasingly during the Late Middle Ages, city states and communessuch as those of the Old Swiss Confederacy also began to use flags as field signs. Regimental flags for individual units became commonplace during the Early Modern period.