A flag is a piece of cloth attached to a pole or mast. Flags were initially created for signalling (as in semaphore), and for the identification of those who displayed them, and are still used for that purpose today; flags used in this latter sense are often called standards. However, flags are also important symbols in their own right. Every country in the world today, and many groups and organizations, have their own flag to symbolize their purpose or aims. Flags are also used in messaging or advertising.

A flag flown at sea is typically known as an ensign. A courteous, peaceable merchant ship or yacht customarily flies its ensign under the flag of whatever nation it is currently visiting. To fly one's ensign alone in foreign water, a foreign port or in the face of a foreign warship traditionally indicates a willingness to fight, with cannon, for the right to do so. This custom is still (2003) taken quite seriously by many naval and port personnel. Misflying an ensign can bring an armed boarding by a naval warship or port authority in many parts of the world.

Yacht ensigns are different from merchant ensigns in order to signal that the yacht is not carrying cargo that requires a customs declaration. Carrying commercial cargo on a boat with a yacht ensign is smuggling in many jurisdictions!

Flags are often designed according to the same principles as the designs of heraldry. A heraldic coat of arms may also be flown as a banner of arms. An example is the U.S. state of Maryland, or the Republic of Kiribati.

One of the most popular uses of a flag is to symbolize a nation or country. Some national flags have been particularly inspirational to other nations, countries, or subnational entities in the design of their own flags. Some prominent examples include:

The Union Flag of the United Kingdom, more commonly (and correctly, when used by warships at sea) called the "Union Jack". British colonies typically fly a flag based on one of the ensigns based on this flag, and many former colonies have retained the design to show their gratitude to the U.K., or allegiance to the Commonwealth. Examples: Australia, Fiji.

Ethiopia was seen as a model by emerging African states of the 1950's and 1960's, as it was one of the oldest continually independent states in Africa. Accordingly, its flag became the source of the Pan-African colors. Examples: Togo, Senegal, Ghana, Mali.

In American and Canadian football, referees use flags to indicate an error has been made in game play. The phrase used for such an indication is flag on the play. The flag itself is a small, weighted handkerchief, tossed on the field at the approximate point of the infraction; the intent is usually to sort out the details after the current play from scrimmage has concluded. In American football, the flag is usually yellow; in Canadian football, it is usually red.

In auto and motorcycle racing, flags are used to communicate with drivers. Most famously, a checkered flag of black and white indicates the end of the race, and victory for the leader.

In football, assistant referees carry small flags along the touch lines. They use the flags to indicate possession on a ball that has gone out of touch, or, most famously, raise the flag overhead to indicate offsides.

In addition, fans of almost all sports will wave flags in the stands to indicate their support for the participants. Many sports teams have their own flags, and in individual sports, fans will indicate their support for a player by waving the flag of his or her home country.

Over time, people made the realization that the adornments were the more visible elements of a vexilloid. This was hastened by the development of sea travel, which called for a means of unambiguous identification over a great distance. Simple, brightly-colored designs which moved with the wind caught the eye best. Today, flags continue to be used to signal between ships or from ship to harbor. An example is an entirely yellow flag, which means that the ship's crew is quarantined for an infectious disease.

The full development of heraldry in about 1200 C.E. also brought sophistication to the development and design of flags. The oldest national flag continually in use is the aforementioned Dannebrog, which dates legendarily from 1219.