In 1687, an enquiry was made by Mr Samuel Pepys, Secretary of the Admiralty, as to the flags worn in the reign of Charles I; and in a manuscript in the British Museum, it is stated, that in the Duke of Buckingham's expedition to the ISLE of RHÉ, in 1627, the Fleet was divided into the RED, BLUE and WHITE squadrons.  In modern English, the document says:

The Duke, now lying at Portsmouth, divided his Fleet into squadrons. Himself, being the admiral and commander-in-chief sailed in the Triumph, flying the standard of England on the main top, and elsewhere, the ensign {called "bloody colours"] for his position as the senior admiral. The Earl of Lindsey, a vice admiral, sailed in the Rainbow flying the standard on the fore top and a ensign to denote his position as second in command. The Lord Harvey, a rear admiral, sailed in Repulse flying his standard on the mizzen top and a ensign to denote his position as third in command.

There were two other squadrons, one under the Earl of Danby with the Flag, and the other under Captain Pennington [made admiral of his squadron] with the Cross.

It will be observed that in this instance the Blue Flag took precedence of the White.

In 1665, in the large Fleet commanded by the Duke of York in person, as Lord High Admiral, Prince Rupert was Admiral of the White, and Sir Thomas Allen of the Blue; and an old drawing shows the three divisions of the Fleet wearing ensigns of their respective colours.

But, although the large Fleets were thus divided, admirals on foreign stations continued to wear the Union Flag at the main, fore or mizzen, according to their ranks as Full, Vice or Rear-Admirals.

Many instances are mentioned of the inconvenience arising from the use of the Royal Flag by private ships, and in 1660, the Duke of York gave an order that the Union Flag should be worn only by the King's ships.

It is clear that the sole object for which the three colours were formerly used was to distinguish the divisions of the Fleet, which often numbered as many as 200 sail.  A variety of ensigns much increased the danger of confusion in action, and it may be observed that, in order to prevent that confusion, Lord Nelson, on going into action at Trafalgar, ordered the whole of his Fleet to hoist the ensign; and it was under that flag, the "Old Banner of England" but with the Union in the upper corner, that the victory was gained.

Latterly, owing to the comparatively small number of ships forming a Fleet, the distinctive colours became of much less importance, while the frequent change of flags on foreign stations was very puzzling to foreigners, often led to mistakes, and in many ways was inconvenient; accordingly, on the 9th of July 1864, by Her Majesty's Order in Council of that date, it was directed that the classification of ships under the denominations of Red, White and Blue squadrons, should be discontinued, and that in future the ensign should be used by all of H.M. Ships of war in commission; the ensign by British merchant ships commanded by officers of the Royal Naval Reserve after obtaining permission from the Admiralty; and the ensign by all other ships and vessels belonging to H.M. subjects.

Other rules governing variations on the ensign exist which are not relevant to my story. However, you would really enjoy looking at the follow site if you enjoyed reading this piece. Look at http://flagspot.net/flags/gb-white_ensign.html#whiteland

The ceremony surrounding 'the colours' {the raising and lowering of the Union Jack forward and the White Ensign aft} was, until the 31st December 1959, known as 'Morning Colours' and 'Evening Colours'.  Then, vide AFO 6/60, beginning on the 1st January 1960, the events became known as 'Colours' and 'Sunset.'

For many many years the White Ensign was not used ashore by Royal Marine Establishments.  These were to be found in every port in the UK {in Portsmouth in two Establishments Gosport and Eastney} and around the world in places like Malta and Singapore.  In these Establishments the Union Flag was flown at the mast head. On the 1st January 1995, they were given permission to fly the White Ensign on the mast gaff and the Union Flag ceased to be used. 

Finally, the RED WHITE and BLUE were used elsewhere in the navy as was the case when I joined in 1953. The Navy was made up from three elements, the Royal Navy [RN]career service {the Navy proper}, the Royal Naval Reserve [RNR] {manned by ex RN personnel and by those who earned their living on the sea or were directly associated with it, so, mercantile seamen, fishermen, lifeboat men etc}, and by the Royal Naval Volunteer Reserve [RNVR] manned by those who wanted to join the navy but had no association with the sea.  Each type of officer wore the stripes of the rank e.g., two stripes for a lieutenant, but each with a different configuration.
 

RN RNR RNVR

 However, whilst the starting point for a would-be naval officer was the Cadet

there were three types of Midshipmen [next step above Cadet] to match the three types of officers shown above which are examples of the officer corps.

These each wore the famous 'snotties patch' on their uniform collar but in different colours, which reflected upon the seniority of the element they belonged to.

RN RNR RNVR