https://www.rmg.co.uk/discover/explore/sailors-cap-ribbons
"Sailors’ hat ribbons during the World Wars
During both World Wars, various security measures were in force concerning cap ribbons and the need to keep the whereabouts of HM ships secret. In December 1914, an order was issued prohibiting the wearing of cap ribbons ashore, and in June 1915 men on leave from battleships, battlecruisers, cruisers and light cruisers were ordered to wear cap ribbons of their depot and not of their ships. During the Second World War, cap ribbons bearing only the letters 'HMS' or 'HM Destroyers/Submarines' were in use."