Blocking

Blocking is a gameplay mechanic which allows players to block many forms of damage.

Java Edition
Shields are used for blocking incoming attacks. one causes the player to slow to a sneaking pace, and after five ticks (0.25 seconds) blockable attacks and knockback coming from the front of the player will be negated. Any effects from the attacker (e.g. wither or fire) will not be placed on the defender. A successful block is indicated by a sound and the shield taking damage.

Blockable attacks include melee attacks, all non-magical projectiles, damage from Thorns, and some explosions. Creeper explosions or TNT ignited by another player are blockable, but TNT ignited by the player or by a redstone mechanism are not. Shields have no effect on other types of damage, such as fall damage and drowning.

Bedrock Edition
Shields are used for blocking incoming attacks. Crouching (sneaking, flying downwards, or moving downwards in water) will activate the shield. Shields also automatically activate when riding mobs, and there is no way to prevent the shield from being activated when riding mobs.

Trivia

 * Blocking allows for the slowest movements possible. This can occur when the player blocks, sneaks, and moves backward while under the effect of the slowness potion while going through cobwebs placed above still water on top of soul sand that is placed on top of ice. This causes the player to move at about 1/200 blocks a second, or 2/25 pixel a second (1 Pixel every 12-13s) on a default 16x16 texture pack. Blocking while sneaking and with the additional events (but without slowness potion) allows the player go at roughly 0.023854961832 blocks per second (1 block every 41.92 seconds) (18 metres per hour).
 * Prior before Snapshot 15w33c of 1.9 (Java Edition) and beta 1.10.0.3 of 1.10.0 (Bedrock Edition), players originally use to block with Swords but only deals less damage from hostile mobs.