A yard is a spar on a mast from which sails are set. It may be constructed of timber or steel or from more modern materials like aluminium or carbon fibre. Although some types of fore and aft rigs have yards, the term is usually used to describe the horizontal spars used on square rigged sails. In addition, for some decades after square sails were generally dispensed with, some yards were retained for deploying wireless (radio) aerials and signal flags.
Note that these terms refer to stretches of the same spar, not to separate component parts.
The yard can rotate around the mast to allow the direction of the vessel to be changed relative to the wind. When running directly downwind the yards are 'squared', pointing perpendicular to the ship's centre line. As the ship is steered closer to the wind the yards are braced round using the braces. When further rotation is obstructed by other bits of rigging (typically the shrouds), the yard is said to be braced "hard round" or "sharp up", as in "sharp up to port". This angle (normally about 60 degrees) limits how close to the wind a square rigged ship can sail.
The yards represent a considerable weight high above the vessel's centre of gravity; to increase stability, especially in heavy weather, some means is normally provided to lower some of the yards when they are not being used to set sails. In nineteenth-century warships (where a large crew was available) this was generally by physically "sending down" the upper yards from the masts and storing them on deck--along with, in many cases, the upper sections of the mast itself. Merchant ships in the age of sail would also do this before sailing in the Southern Ocean. On modern tall ships the yards are not designed to be sent down on deck, but 'lifting yards' that can be raised and lowered along a short section of mast using a halyard are often used.
As well as rotating round the mast and moving up and down along it, the yards on many ships are designed to tilt relative to the mast. This allows the sails to be set more efficiently when the ship is heeled over by raising the leeward yardarm to bring the yard closer to the horizontal. This is achieved using the lifts, which run from each yardarm to the mast some way above. On some ships only the course lifts can be adjusted (the others being fixed lifts intended only to support the yard when not hoisted), with the influence of the course yard being sufficient to tilt all the sails. Some ships have their yards mounted on mechanical swivels with no possibility of tilting them.