Her or His Majesty's Ship (HMS) is the ship prefix used for ships of the navy in some monarchies, either formally or informally.
In the Swedish Navy (formerly the Royal Swedish Navy), all vessels are given the prefix HMS (Hans or Hennes Majestäts Skepp). This is true for both surface and submarine vessels.
Abroad, Swedish navy ships are sometimes given the prefix HSwMS (for His Swedish Majesty's Ship), this in order so that any confusion with other uses of HMS can be avoided.
In the British Royal Navy, the prefix was originally always quoted in full; the first recorded use of the abbreviated form, "HMS", was in 1789 in respect of HMS Phoenix. Formerly, HBMS (for His or Her Britannic Majesty's Ship) was also used.
Submarines in Her Majesty's service also use the prefix HMS, standing for "Her Majesty's Submarine". The Royal Yacht Britannia, which was a commissioned ship in the Royal Navy, was known as HMY Britannia. Otherwise all ships in the Royal Navy are known as HM Ships, though formerly when a distinction was made between three-masted ship-rigged ships and smaller vessels they would be called HM Frigate X, or HM Sloop Y.
The prefix "HMS" is also used by shore establishments that are commissioned "stone frigates" in the Royal Navy. Examples include HMS Excellent, which is a training school located on an island in Portsmouth Harbour, and HMS Vulcan, in Caithness in the Highland area of Scotland, which is established to test the design of nuclear power systems for use in submarines.
The sample ship name used by the Royal Navy to signify a hypothetical vessel is HMS Nonsuch. This is a name that has been used by the Royal Navy in the past; on the eve of World War II the name devolved to the Royal Canadian Navy. HMCS Nonsuch is at present the "stone frigate" of the Edmonton Division of the Canadian Naval Reserve.