Fouls (a type of rule violation) are punished with penalties against the offending team. Most penalties result in moving the football towards the offending team's end zone. If the penalty would move the ball more than half the distance towards the offender's end zone, the penalty becomes half the distance to the goal instead of its normal value.
Most penalties result in replaying the down. Some defensive penalties give the offense an automatic first down. Conversely, some offensive penalties result in loss of a down (loss of the right to repeat the down).If a penalty gives the offensive team enough yardage to gain a first down, they get a first down, as usual.
If a foul occurs during a down, an official throws a yellow penalty flag near the spot of the foul. When the down ends, the team that did not commit the foul has the option of accepting the penalty, or declining the penalty and accepting the result of the down.