How do yellow and red cards work in soccer?

In soccer, or football depending on where you live, the use of yellow and red cards can get confusing, especially to those who are new to the sport. The question of how do yellow and red cards work in soccer is one that many of those just learning about the sport often have. It is sometimes difficult to understand exactly how does a player get a yellow card or how does a player get a red card? To help with this I have made up a brief video tutorial that can be found on YouTube. Rather than type it all out, head over and check it out.