Ask coding questions

← Back to all posts
Codepen
WilliamXing (49)

Why is it that everytime I copy paste code from codepen, it never works?

Answered by OldWizard209 (1276) [earned 5 cycles]
View Answer
Comments
hotnewtop
OldWizard209 (1276)

It may because there are some pre-installed frameworks in codepen that are being used. Also, make sure to put all the code in the HTML boilerplate on replit.

btfuss (146)

Before importing, if the HTML, CSS, or Javascript has a () next to it then click the three dot thingy and click View Compiled (Html, css, or js). Then you can import the code in the 3rd step

Second, if in the JS it has a $ in the code, in the head tag put
<script src="jquery-3.5.1.min.js"></script> to import jquery.

So, third it doesn't include the first couple of tags:

<html>
<head>
<link rel="stylesheet" href="style.css">
<title>(Site Name)</title>
</head>
<body>
<--! CODEPEN HERE -->

<script src="script.js"></script>
</body>
</html>

Put your CSS in the style.css file, and your javascript in script.js, html in index.html and boom everything works!