Walling

Walling refers to the use of buildings in order to make a choke more narrow (and thus easier to defend) or even completely blocked off in some situations. Applications are usually defensive, but they can also be used offensively to trap players in early on, or in any likely place of battle (usually late game) to give an advantage to your ranged units fight against melee (or lesser ranged) units.

Terran players create walls much more frequently than other races do because of the versatility they have from the Supply Depot's ability to lower into the ground as well as the ability of most of their buildings to Lift Off. Most common Terran walls are composed of two Supply Depots and a Barracks or one Barracks, one Factory and one Add on.

Zerg players sometimes use buildings to wall off, to protect against a run by. On the other hand, when in need of a block, Zerg often use units like Queens or Roaches. It is fairly common however to use buildings at the natural expansion versus Terran to create a narrow choke that is easy to block against a Hellion run by or Zerglings. Zerg also use two Queens to block a ramp vs Ling-Run-Bys or Hellion-Harass. In LotV a wall can help against Adepts. Their ability Psionic Transfer would allow them to bypass Queens and other units. If a Zerg wants to deny this kind of Scouting he should build a full wall using a Spine to block the Adepts.

For Protoss players walling is most common when playing against Zerg. A Protoss player will usually wall the entrance to his main or wall his Natural, leaving a 1x1 gap between buildings, allowing all units to pass through while also allowing the gap to be completely blocked with a Zealot on hold position. This prevents Zerglings from entering the base, while still allowing a Mineral walked probe to leave.

Alternatively, on certain maps, some players tend to build their initial Pylon and later their Gateway(s) at the choke of their Natural so that they can wall it off later, making their expansion easier to defend.

As you can see (3rd screenshot) this wall has a major disadvantage vs Cheese like 7RR. But since 1Base-All-Ins are very rare these days, you probably have to defend an All-In at your Natural. This Noob-Wall is build fast and you can use Photon Overcharge on both Pylons in LotV.

FFE style

YufFE style

Zealot on "Hold Position"? Open Pro-Wall resulting in a run-by

Which kind of wall you want is depending on your BO and your style. Some people do not like to expose their Probes to Zerglings. Other players might argue, that four buildings (one Pylon) to close their wall is more efficient than six buildings (two Pylons). A large Choke like the one on Ruins of Seras requires training. Walling "YufFE style" is done with one Pylon and three "big" buildings. "FFE style" needs two Pylons and four big buildings.

On Maps with "inbase" (aka "backdoor") or "pocket natural expansions" like

you should use a Pro-Wall instead of a Noob-Wall, since a Pylon is vulnerable to Bane Busts. A Pro-Wall would force the Zerg to build more Banelings. Why? A Pylon has "200/200" and is killed more easily than a Core with "550/550".

The screenshot (Alterzim) on the right hand side shows two Master players (ZvP). Protoss forgot to place his Zealot right, so Zerg makes a run-by with Speedlings. It's almost impossible to make that mistake with a Noob-Wall. A good building placement will help you, to prevent such mistakes and death by All-In. But without Scouting you will probably die anyway.

In StarCraft II, any buildings adjacent to each other horizontally or vertically will completely block units from passing between them.
If two buildings are placed diagonally so that only their corners meet, only small sized units can pass between them. To see which units can pass between diagonally placed buildings see the #Units that can pass through semi-walls.

Vespene Geysers act exactly as a normal building would for walling purposes.

These positions (as well as all positions in between) result in a "tight wall"; no units can pass through. The same applies to similarly placed buildings in horizontal positions.

This placement results in a "semi-wall" through which only small sized units can pass (see list of units below).

The Hatchery/Nexus/CC (5x5 buildings) seem to be exceptions. If a CC is part of a wall-in, it needs to have a common border of length 2 (instead of just 1) with the next building. A common border of length 1 results in a semi-wall, while corner-to-corner placement allows medium size units (e.g. Stalkers, Roaches, but not tanks) through.

Spore and Spine Crawlers allow small units (e.g. Zealots, Marauders) to pass through them even when arranged next to each other. They also allow medium size units (e.g. Immortals, but not tanks) to pass if arranged off-by-one.

If two buildings are placed one space apart from each other, that space can be blocked by any unit, as long as it is placed right between them and ordered to Hold Position. This technique is most commonly used by Protoss players that wall their ramp using two buildings and block the gap with their first Zealot to prevent any Zerglings from running through.

Enemy units that have equal or greater range than your own units can safely attack the wall itself, while your own units cannot attack back from behind the wall. This is a reason why Protoss players do not normally wall against Terrans, who get ranged Marines very early. Similarly, Protoss players can sometimes take advantage of the range of a Void Ray to attack a Terran wall from outside the range of defending Marines.

A wall composed of weaker structures such as Supply Depots or Pylons early on can present a false sense of security, as Zerg players can perform a Baneling Bust to easily break down the wall, leaving the defender with few units to defend against the flood of Zerglings breaching your wall. For this reason, Terran players tend to use Barracks and Factories for their wall as they are much harder to destroy, and can still provide the door function by lifting off. Protoss do not have this advantage and would have to destroy the building (or cancel before it finishes construction) to provide access.

If your wall of Supply Depots or Pylons is breached, you can become supply blocked, rendering you unable to reinforce or produce more units during the attack. Protoss players should also take care not to rely on a single wall Pylon to power important buildings, especially those that would be important in defending against a rush such as Gateways or Photon Cannons.