This is fairly simple example code. If you don't understand how it works, and how to apply it to your own page, then it is time to go work though some tutorials. I would recommend the ones over at
w3schools. Until you have a reasonable understanding of something, it is unlikely that you can use it properly.