His or Her Majesty's Ship, abbreviated HMS and H.M.S., is the ship prefix used for ships of the navy in some monarchies. Derived terms such as "HMAS" and equivalents in other languages such as "SMS" are used.
In the British Royal Navy, the prefix was originally always quoted in full; the first recorded use of the abbreviated form, "HMS", occurred in 1789 in respect of HMS Phoenix.From 1707 to c1800 HBMS (for His 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, 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 was given[by whom?] to the Royal Canadian Navy. As of 2012HMCS Nonsuch was the "stone frigate" of the Edmonton Division of the Canadian Naval Reserve.
Prefixing the name by "the", as in "the HMS Ark Royal", while common, is considered bad grammar.
British government ships not in the Royal Navy have other designations, such as "RFA" for ships in the Royal Fleet Auxiliary.
Historically, variants on "HMS" have been used by the navies of British colonies. The practice is maintained in several Commonwealth realms (states which recognise Queen Elizabeth II as their monarch).
Seiner Majestät Schiff (pronounced ['zan? maj?s't?:t f]; German: "His Majesty's Ship", abbreviated to S.M.S. or SMS) was the ship prefix used by the Prussian Maritime Enterprise (Seehandlung), the Prussian Navy, the Imperial German Navy (Kaiserliche Marine) and the Austro-Hungarian Navy. It was created by translating the British prefix into German.
It was sometimes also abbreviated to S.M. or SM (for Seiner Majestät) when a ship was mentioned by class, such as S.M. Kleiner Kreuzer Emden ("His Majesty's Light Cruiser Emden").
Special forms included
International prefixes for ships of the Royal Netherlands Navy is HNLMS (His/Her Netherlands Majesty's Ship). The Netherlands navy itself uses the prefixes Zr.Ms. (Zijner Majesteits, His Majesty's) when a king is on the throne, and Hr.Ms. (Harer Majesteits, Her Majesty's) when there is a queen. This happens automatically at the moment of coronation. 
The Royal Norwegian Navy vessels have since 1946 been given the ship prefix "KNM", short for Kongelig Norske Marine (Royal Norwegian Navy). In English, they are given the prefix "HNoMS", short for "His/Her Norwegian Majesty's Ship" ("HNMS" could be also used for the Royal Netherlands Navy, for which "HNLMS" is used instead). Coast Guard vessels are given the prefix "KV" for KystVakt (Coast Guard) in Norwegian and "NoCGV" for Norwegian Coast Guard Vessel in English.
Prior to World War II & the subsequent ousting of the monarchy & occupation of the Soviet Union postwar, all Royal Romanian Navy vessels were given the prefix NMS (Nava Majestii Sale) or "His/her Majesty's Ship".
Abroad, Swedish navy ships are sometimes given the prefix HSwMS (for His Swedish Majesty's Ship), to avoid confusion with other uses of the HMS prefix.
Some, but apparently not all, other navies also use prefixes with their ships' names. Perhaps the best known of these is 'HMS' (His or Her Majesty's Ship), long used by the Royal Navy. In earlier times this was also seen as 'HBMS,' for 'His Britannic Majesty's Ship.'