A flag is a piece of fabric (most often rectangular or quadrilateral) with a distinctive design that is used as a symbol, as a signaling device, or as decoration.
Due to the use of flags by military units, 'flag' is also used as the name of some military units.
During the peak of the age of sail, beginning in the early 17th century, it was customary (and later a legal requirement) for ships to carry flags designating their nationality; these flags eventually evolved into the national flags and maritime flags of today.
Use of flags outside of military or naval context begins only with the rise of nationalist sentiment by the end of the 18th century; the earliest national flags date to that period, and during the 19th century it became common for every sovereign state to introduce a national flag.
- The flag of Denmark, the Dannebrog, is attested in 1478, and is the oldest national flag still in use. It inspired the cross design of the other Nordic countries : Norway, Sweden, Finland, Iceland, and regional Scandinavian flags for the Faroe Islands, Åland, Scania and Bornholm, as well as flags for the non-Scandinavian Shetland and Orkney. 
- The flag of the Netherlands is the oldest tricolour. Its three colours of red, white and blue go back to Charlemagne's time, the 9th century. The coastal region of what today is the Netherlands was then known for its cloth in these colours. Maps from the early 16th century already put flags in these colours next to this region, like Texeira's map of 1520. A century before that, during the 15th century, the three colours were mentioned as the coastal signals for this area, with the 3 bands straight or diagonal, single or doubled. As state flag it first appeared around 1572 as the Prince's Flag in orange–white–blue. Soon the more famous red–white–blue began appearing, becoming the prevalent version from around 1630. Orange made a come back during the civil war of the late 18th century, signifying the orangist or pro-stadtholder party. During WW2 the pro-nazi NSB used it. Any symbolism has been added later to the three colours, although the orange comes from the House of Orange-Nassau. Surprisingly, this use of orange comes from Nassau, which today uses orange-blue, not from Orange, which today uses red-blue. However, the usual way to show the link with the House of Orange-Nassau is the orange pennant above the red-white-blue. It's said that the Dutch Tricolour has inspired many flags but most notably those of Russia, New York City, and South Africa (the 1928–94 flag as well the current flag). As the probable inspiration for the Russian flag, it is the source too for the Pan-Slavic colours red, white and blue, adopted by many Slavic states and peoples as their symbols. Examples: Slovakia, Serbia, and Slovenia.
- The national flag of France was designed in 1794. As a forerunner of revolution, France's tri-colour flag style has been adopted by other nations. Examples: Italy, Costa Rica, Dominican Republic, Ireland, Haiti, Romania, Mexico, etc.
- The Union Flag (Union Jack) of the United Kingdom is the most commonly used. British colonies typically flew a flag based on one of the ensigns based on this flag, and many former colonies have retained the design to acknowledge their cultural history. Examples: Australia, Fiji, New Zealand, Tuvalu, and also the Canadian provinces of Manitoba, Ontario and British Columbia, and the American state of Hawaii; see commons:Flags based on British ensigns .
- The flag of the United States is nicknamed The Stars and Stripes or Old Glory. Some nations imitated this flag so as to symbolize their similarity to the United States and/or the American Revolution. Examples: Liberia, Chile, Uruguay, Taiwan (ROC), Malaysia and the French region of Brittany.
- Ethiopia was seen as a model by emerging African states of the 1950s and 1960s, as it was one of the oldest independent states in Africa. Accordingly, its flag became the source of the Pan-African colours, or 'Rasta colours'. Examples: Benin, Togo, Senegal, Ghana, Mali, Guinea.
- The flag of Turkey, which is very similar to last flag of the old Ottoman Empire, has been an inspiration for the flag designs of many other Muslim nations. During the time of the Ottomans the crescent began to be associated with Islam and this is reflected on the flags of Algeria, Azerbaijan, Comoros, Libya, Mauritania, Pakistan and Tunisia.
- The Pan-Arab colours, green, white, red and black, are derived from the flag of the Great Arab Revolt as seen on the flags of Jordan, Libya, Kuwait, Sudan, Syria, the United Arab Emirates, Western Sahara, Egypt, Iraq, Yemen and Palestine.
- The Soviet flag, with its golden symbols of the hammer and sickle on a red field, was an inspiration to flags of other communist states, such as East Germany, People's Republic of China, Vietnam, Angola, Afghanistan (1978–1980) and Mozambique.
- The flag of Venezuela, created by Francisco de Miranda to represent the independence movement in Venezuela that later gave birth to the "Gran Colombia", inspired the flags of Colombia and Ecuador, both sharing three bands of yellow, blue and red with the flag of Venezuela.
- The flag of Argentina, created by Manuel Belgrano during the war of independence, was the inspiration for the United Provinces of Central America's flag, which in turn was the origin for the flags of Guatemala, Honduras, El Salvador, and Nicaragua.
- Flags of Native American nations in the United States are common and many tribes have chosen a flag as their symbol of choice.
National flag designs are often used to signify nationality in other forms, such as flag patches.
A civil flag is a version of the national flag that is flown by civilians on non-government installations or craft.
Four distinctive African flags currently in the collection of the National Maritime Museum in Britain were flown in action by Itsekiri ships under the control of Nana Olomu during conflict in the late 19th century.
Flags are particularly important at sea, where they can mean the difference between life and death, and consequently where the rules and regulations for the flying of flags are strictly enforced.
Shapes and designs
Flags are usually rectangular in shape (often in the ratio 2:3, 1:2, or 3:5), but may be of any shape or size that is practical for flying, including square, triangular, or swallow tailed.
Many flags are dyed through and through to be inexpensive to manufacture, such that the reverse side is the mirror image of the obverse (front) side, generally the side displayed when the flag is flying from the observer's point of view from left, the side of the pole, to right.
Some complex flag designs are not intended for through and through implementation, requiring separate obverse and reverse sides if made correctly.
Common designs on flags include crosses, stripes, and divisions of the surface, or field, into bands or quarters—patterns and principles mainly derived from heraldry.
Colours are normally described with common names, such as "red", but may be further specified using colourimetry.
The general parts of a flag are: canton—the upper inner section of the flag; field or ground—the entire flag except the canton, and the field and hoist ends; fly end—the furthest edge from the hoist end; and hoist end—the edge used to attach the flag to the hoist.
Vertical flags are sometimes used in lieu of the standard horizontal flag in central and eastern Europe, particularly in the German-speaking countries.
The standard horizontal flag (no. 1 in the preceding illustration) is nonetheless the form most often used even in these countries.
The vertical flag (German: Hochformatflagge or Knatterflagge; no. 2) is a vertical form of the standard flag.
The vertical flag for hoisting from a beam (German: Auslegerflagge or Galgenflagge; no. 3) is additionally attached to a horizontal beam, ensuring that it is fully displayed even if there is no wind.
The vertical flag for hoisting from a horizontal pole (German: Hängeflagge; no. 4) is hoisted from a horizontal pole, normally attached to a building.
The vertical flag for hoisting from a crossbar or banner (German: Bannerflagge; no. 5) is firmly attached to a horizontal crossbar from which it is hoisted, either by a vertical pole (no. 5a) or a horizontal one (no. 5b).
Flags can play many different roles in religion.
As languages rarely have a flag designed to represent them,  it is a common but unofficial practice to use national flags to identify them.
- representing language skills of an individual, like a staff member of a company
- displaying available languages on a multilingual website or software.
Though this can be done in an uncontroversial manner in some cases, this can easily lead to some problems for certain languages:
- languages generating language secessionism, such as Serbo-Croatian which since the breakup of Yugoslavia in 1991, has lost its unitary codification and its official unitary status and is now divided into four official languages: Croatian language, Bosnian language, Serbian language and the Montenegrin language
- languages spoken in more than one country, such as English or Arabic.
In this second case, common solutions include symbolising these languages by:
- the flag of the country where the language originated
- the flag of the country having the largest number of native speakers
- a mixed flag of the both (when this is not the same)
- the flag of the country most identified with that language in a specific region (e.g. Portuguese Language: Flag of Portugal in Europe and Flag of Brazil in South America). A Portugal-Brazil mixed flag, usually divided diagonally, is also a possibility.
Thus, on the Internet, it is common to see the English language associated with the flag of the United Kingdom, or sometimes the flag of England, the flag of the United States or a U.S.-UK mixed flag, usually divided diagonally.
Because of their ease of signalling and identification, flags are often used in sports.
- In association football, linesmen carry small flags along the touch lines. They use the flags to indicate to the referee potential infringements of the laws, or who is entitled to possession of the ball that has gone out of the field of play, or, most famously, raising the flag to indicate an offside offence. Officials called touch judges use flags for similar purposes in both codes of rugby.
- In American and Canadian football, referees use penalty flags to indicate that a foul has been committed 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 orange. In the National Football League, coaches also use red challenge flags to indicate that they wish to contest a ruling on the field.
- In yacht racing, flags are used to communicate information from the race committee boat to the racers. Different flags hoisted from the committee boat may communicate a false start, changes in the course, a cancelled race, or other important information. Racing boats themselves may also use flags to symbolize a protest or distress. The flags are often part of the nautical alphabetic system of International maritime signal flags, in which 26 different flags designate the 26 letters of the Latin alphabet.
- In auto and motorcycle racing, racing flags are used to communicate with drivers. Most famously, a checkered flag of black and white squares indicates the end of the race, and victory for the leader. A yellow flag is used to indicate caution requiring slow speed and a red flag requires racers to stop immediately. A black flag is used to indicate penalties.
- In addition, fans of almost all sports 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.
- Capture the flag is a popular children's sport.
- In Gaelic football and Hurling a green flag is used to indicate a goal while a white flag is used to indicate a point
- In Australian rules football, the goal umpire will wave two flags to indicate a goal (worth six points) and a single flag to indicate a behind (worth one point).
- For safety, dive flags indicate the locations of underwater scuba divers or that diving operations are being conducted in the vicinity.
- In water sports such as Wakeboarding and Water-Skiing, an orange flag is held in between runs to indicate someone is in the water.
- In golf, the hole is marked with a flag. The flagpole is designed to fit centered within the base of the hole and is removable. Many courses will use colour-coded flags to determine a hole location at the front, middle or rear of the green. However colour-coded flags are not used in the professional tours.
- Flag poles with flags of all shapes and sizes are used by marching bands, drum corps, and winter guard teams use flags as a method of visual enhancement in performances.
Social and political movements have adopted flags, to increase their visibility and as a unifying symbol.
Flags are often representative of an individual's affinity or allegiance to a country, team or business and can be presented in various ways.
Reasons for closing the beach include:
- dangerous rip
- hurricane warning
- no lifeguards in attendance
- overpolluted water
- waves too strong
A surf flag exists, divided into four quadrants.
Signal flag"India" (a black circle on a yellow square) is frequently used to denote a "blackball" zone where surfboards cannot be used but other water activities are permitted.
Railways use a number of coloured flags.
- red = stop
- yellow = proceed with care
- green or white = proceed.
- a flag of any colour waved vigorously means stop
- a blue flag on the side of a locomotive means that it should not be moved because someone is working on it (or on the train attached to it). A blue flag on a track means that nothing on that track should be moved. The flag can only be removed by the person or group that placed it. In the railway dominated steel industry this principle of "blue flag and tag" was extended to all operations at Bethlehem Steel, Lackawanna, NY. If a man went inside a large machine or worked on an electrical circuit for example, his blue flag and tag was sacrosanct.  The "Lock Out/Tag Out" practice is similar and now used in other industries to comply with safety regulations.
At night, the flags are replaced with lanterns showing the same colours.
Flags displayed on the front of a moving locomotive are an acceptable replacement for classification lights and usually have the following meanings (exact meanings are set by the individual railroad company):
- white = extra (not on the timetable)
- green = another section following
- red = last section
Additionally, a railroad brakeman will typically carry a red flag to make his or her hand signals more visible to the engineer.
A flagpole, flagmast, flagstaff, or staff can be a simple support made of wood or metal.
Since 23 September 2014, the tallest free-standing flagpole in the world is the Jeddah Flagpole in Saudi Arabia with a height of 171 m (561 ft), beating the formerly record holding Dushanbe Flagpole in Tajikistan   (height: 165 m, 541 ft), National Flagpole in Azerbaijan (height: 162 m, 531 ft)  and the North Korean flagpole at Kijŏng-dong (height: 160 m, 520 ft).
The tallest flagpole in the United Kingdom from 1959 until 2013 stood in Kew Gardens.
The current tallest flagpole in the United States (and the tallest containing an American flag) is a 400 ft (120 m) pole completed near Memorial Day 2014 and custom-made with a large 11 feet (3.4 m) base in concrete by wind turbine manufacturer Broadwind Energy, which is situated on the north side of the Acuity Insurance headquarters campus along Interstate 43 in Sheboygan, Wisconsin and is visible from Cedar Grove.
Hoisting the flag
Hoisting the flag is the act of raising the flag on the flagpole.
A flag-raising squad is a group of people, usually troops, cadets, or students, that marches in and brings the flags for the flag-hoisting ceremony.
Flags and communication
Semaphore is a form of communication that utilizes flags.
The colours of the flags can also be used to communicate.
Orientation of a flag is also used for communication, though the practice is rarely used given modern communication systems.
When blown by the wind, flags are subject to wave-like motions that grow in amplitude along the length of the flag.
- Gallery of sovereign state flags
- List of flag names
- Lists of flags
- Timeline of national flags
- Unofficial flags
- False flag
- Flag Day
- Flag desecration
- Flag protocol
- Flag patch
- Flag semaphore
- Flag throwing
- Glossary of vexillology
- Pledge of Allegiance
- Standard-bearer (also enumerates various types of standards, both flag types and immobile ensigns)