HTML rgb fade?original code

The original code pen example is working fine, however, if I were to copy the code one by one into a new codepen, the code just doesn’t work. I’ve also copied the code into an html page (I used inline to have it on one page) but again, it has the same issue as copying to code to a new codepen. Is there anything I should know that I might need to do to get it to work properly?

(I think you might have posted in the wrong forum.)