Any structure built to withstand attack can be termed a "fort", "fortress", or "fortification". Forts range from isolated towers to entire walled cities. Castles, the large forts of medieval Western Europe, often served as a medieval city's civic, commercial, and military hub. Castles were also erected in isolated regions as military outposts.K190-91,2
During the impoverished early Middle Ages (ca. 500-1000), forts in Western Europe were relatively small and crude. The construction of impressive castles dates to the later Middle Ages (ca. 1000-1500), when cities finally reappeared. The heart of castle-building innovation was France.
The standard early castle type was motte-and-bailey, which featured a main building (the keep) positioned on top of a hill; if no natural hill was available, an artificial hill (a motte) was raised. The keep was encircled by such barriers as defensive walls, palisades (fences of tightly-spaced stakes), ditches, and raised circles of earth. The bailey was the space between the keep and the outermost wall, from which troops could defend the keep.1,2
Castle designs became much larger and stronger throughout the High Middle Ages (ca. 1000-1300). Stone replaced wood as the standard construction material (for both the keep and defensive walls), ditches were expanded into deep moats (which compelled the invention of the drawbridge), and the castle entrance was protected with a portcullis (massive iron-and-wood door). The keep became a stronghold of last resort as more buildings were added, including great halls, chapels, residences, towers, barracks, and stables. Often, the buildings (and walls) of a castle did not stand separately, but were joined together in a massive complex.1,2
Square keeps and towers were superseded by round ones; a key improvement, given that the destruction of one corner of a square building eases the removal of adjacent walls. Narrow slits in walls allowed archers to fire upon attackers, and a battlement (wall with regular gaps) along the top of a wall or building gave protection to troops stationed there. (Another term for battlement is crenellation; each section of wall is termed a "merlon", while each space is called a "crenel".)K190-91,2,2
The age of the castle continued through the Late Middle Ages (ca. 1300-1500), after which cannons rendered castles obsolete.2 Subsequent forts were compact, low-lying, and replete with artillery pieces. Nobles from the Renaissance onward lived in relatively unfortified residences (referred to as mansions or palaces).1
During the Gothic Revival period (ca. 1750-1900), medieval nostalgia impelled the construction of many castle-like residences. The most famous example is likely Neuschwanstein Castle, Germany.
2 - "Castle", Encarta 2004.