When an official sees a foul, he throws a yellow flag. The play finishes, and then the referee announces the foul, the player and the penalty.
Penalties are measured in yards, and the ball is moved the full distance against the team that fouled.
If an official throws a flag, players stop only when the whistle blows. The play goes on as normal.
Most penalties are 5, 10 or 15 yards. Examples of 5 yards are false start and offside. Holding by the offense is 10 yards. Unnecessary roughness and unsportsmanlike conduct are 15 yards.
Some penalties are not measured by a set number of yards. They are enforced from the spot of the foul, such as defensive pass interference.
The size of the penalty shows how serious the foul is.
The team that did not commit the foul can accept the penalty, or decline it and keep the result of the play.
If both teams commit a foul on the same play, the fouls offset and the down is replayed.
A team declines a penalty when the play gave a better result than the yardage.
Example
The defense is offside, but the offense still throws a 30-yard pass. The offense declines the 5-yard penalty and keeps the 30 yards.
Some offensive fouls cost the offense a down as well as yards, for example intentional grounding. Some defensive fouls give the offense an automatic first down.
A penalty never moves the ball more than half the distance to the goal line.
The referee uses a microphone to explain each penalty to the stadium and TV.