In engineering, a foundation is the element of a structure which connects it to the ground or more rarely, water (as with floating structures), transferring loads from the structure to the ground. Foundations are generally considered either shallow or deep.  Foundation engineering is the application of soil mechanics and rock mechanics ( geotechnical engineering) in the design of foundation elements of structures.
Foundations provide the structure's stability from the ground:
The design and the construction of a well-performing foundation must possess some basic requirements:
Buildings and structures have a long history of being built with wood in contact with the ground.   Post in ground construction may technically have no foundation. Timber pilings were used on soft or wet ground even below stone or masonry walls.  In marine construction and bridge building a crisscross of timbers or steel beams in concrete is called grillage. 
Dry stone and stones laid in mortar to build foundations are common in many parts of the world. Dry laid stone foundations may have been painted with mortar after construction. Sometimes the top, visible course of stone is hewn, quarried stones.  Besides using mortar, stones can also be put in a gabion.  One disadvantage is that if using regular steel rebars, the gabion would last much less long than when using mortar (due to rusting). Using weathering steel rebars could reduce this disadvantage somewhat.
Rubble trench foundations are a shallow trench filled with rubble or stones. These foundations extend below the frost line and may have a drain pipe which helps groundwater drain away. They are suitable for soils with a capacity of more than 10 tonnes/m2 (2,000 pounds per square foot).
A granary on staddle stones, a type of padstone
Black Eagle Dam – cross-section of construction plans for 1892 structure
Davis House dry-laid stone foundation ruin, Gardiner, NY
A basic type of rubble trench foundation
Often called footings, are usually embedded about a meter or so into soil. One common type is the spread footing which consists of strips or pads of concrete (or other materials) which extend below the frost line and transfer the weight from walls and columns to the soil or bedrock.
Another common type of shallow foundation is the slab-on-grade foundation where the weight of the structure is transferred to the soil through a concrete slab placed at the surface. Slab-on-grade foundations can be reinforced mat slabs, which range from 25 cm to several meters thick, depending on the size of the building, or post-tensioned slabs, which are typically at least 20 cm for houses, and thicker for heavier structures.
Another way to install ready-to-build foundations that is more environmentally friendly is to use screw piles. Screw pile installations have also extended to residential applications, with many homeowners choosing a screw pile foundation over other options. Some common applications for helical pile foundations include wooden decks, fences, garden houses, pergolas, and carports.
Used to transfer the load of a structure down through the upper weak layer of topsoil to the stronger layer of subsoil below. There are different types of deep footings including impact driven piles, drilled shafts, caissons, screw piles, geo-piers[ clarification needed] and earth-stabilized columns[ clarification needed]. The naming conventions for different types of footings vary between different engineers. Historically, piles were wood, later steel, reinforced concrete, and pre-tensioned concrete.
A type of deep foundation which uses a single, generally large-diameter, structural element embedded into the earth to support all the loads (weight, wind, etc.) of a large above-surface structure.
Many monopile foundations  have been used in recent years for economically constructing fixed-bottom offshore wind farms in shallow-water subsea locations.  For example, a single wind farm off the coast of England went online in 2008 with over 100 turbines, each mounted on a 4.74-meter-diameter monopile footing in ocean depths up to 16 meters of water. 
A floating foundation is one that sits on a body of water, rather than dry land. This type of foundation is used for some bridges and floating buildings.
Foundations are designed to have an adequate load capacity depending on the type of subsoil/rock supporting the foundation by a geotechnical engineer, and the footing itself may be designed structurally by a structural engineer. The primary design concerns are settlement and bearing capacity. When considering settlement, total settlement and differential settlement is normally considered. Differential settlement is when one part of a foundation settles more than another part. This can cause problems to the structure which the foundation is supporting. Expansive clay soils can also cause problems.