A foul occurs when a player commits an offence listed in the Laws of the Game while the ball is in play. The offences that constitute a foul are listed in Law 12. Handling the ball deliberately, tripping an opponent, or pushing an opponent, are examples of "penal fouls", punishable by a direct free kick or penalty kick depending on where the offence occurred. Other fouls are punishable by an indirect free kick.

The referee may punish a player's or substitute's misconduct by a caution (yellow card) or dismissal (red card). A second yellow card in the same game leads to a red card, which results in a dismissal. A player given a yellow card is said to have been "booked", the referee writing the player's name in their official notebook. If a player has been dismissed, no substitute can be brought on in their place and the player may not participate in further play. Misconduct may occur at any time, and while the offences that constitute misconduct are listed, the definitions are broad. In particular, the offence of "unsporting behaviour" may be used to deal with most events that violate the spirit of the game, even if they are not listed as specific offences. A referee can show a yellow or red card to a player, substitute, substituted player, and to non-players such as managers and support staff.

Rather than stopping play, the referee may allow play to continue if doing so will benefit the team against which an offence has been committed. This is known as "playing an advantage". The referee may "call back" play and penalise the original offence if the anticipated advantage does not ensue within "a few seconds". Even if an offence is not penalised due to advantage being played, the offender may still be sanctioned for misconduct at the next stoppage of play.

The referee's decision in all on-pitch matters is considered final. The score of a match cannot be altered after the game, even if later evidence shows that decisions (including awards/non-awards of goals) were incorrect.
What is a yellow or red card in soccer?
In the game of soccer, whenever a player commits a foul, the referee can give a player a yellow card or a red card. A yellow card is a caution/warning. A red card is a dismissal and the player has to leave the field.