A compromise led to the creation of the first Union Flag.
On 12 April 1606, the National Flags of Scotland and England were united for use at sea, thus making the first Union 'Jack'. Ashore however, the old flags of England and Scotland continued to be used by their respective countries.
A royal decree declared that the ships of the Kingdom of Great Britain "shall bear on their maintops the red cross, commonly called St. George's cross, and the white cross, commonly called St. Andrew's cross."
When the red cross of England was put onto the flag of Scotland, a white border was added around the red cross for reasons of heraldry. (The rules of heraldry demanded that two colours must never touch each other.)
On 28th July, 1707, during the reign of Queen Anne, this flag was by royal proclamation made the National flag of Great Britain, for use ashore and afloat.