CodePen is a popular online code editor used by many developers around the world. It is also one of the recommended editors you can use for the freeCodeCamp curriculum.

CodePen is only for frontend projects and supports HTML, CSS, and JavaScript. If you need to build a project with a backend component, then you will need to use a different editor.

In this article, I will discuss the following:

How to sign up for a free account

When you visit the CodePen website, you will be able to login with the following options:

  • Twitter account
  • Facebook account
  • GitHub account

You can also signup with an email address where you will create a username and password.

Once you create the account, you should receive an email from CodePen. Open up that message and verify your email address.

email-from-codepen

Differences between Pens and Projects

Pens

After verifying your email address, you should be taken straight to the Pen editor. If the editor does not show up, then you can click on Pen located on the left hand side of the homepage.

Screen-Shot-2021-10-29-at-11.49.12-PM

A Pen editor is broken up into three sections of HTML, CSS and JavaScript.

pen-editor

This editor does not support multiple HTML, CSS and JavaScript files. Pens are great for smaller scale creations.  

If you are looking to write more than 5,000 lines of code then you should consider a project instead.

With the free account, you can have as many Pens as you like.

Projects

If you want to create a project, then click on Project, which is located at the top left hand corner of the home page.

Screen-Shot-2021-10-29-at-11.50.29-PM

A project editor supports multiple HTML, CSS, and JavaScript files.

project-editor

With the free account, you can only have one project and 10 files. If you are interested in creating more projects, you will need to upgrade to the Pro account.  

Basic Features of the Pen Editor

Formatting Options

If you click on the dropdown arrow on any of the three editors, you will see an option to format your code.

This is a helpful tool to ensure that your code is properly formatted and readable by other developers.

before-format
after-format

You can also go to the Behavior section of Pen Settings, and choose the Format on Save option.  

pen-settings
format-on-save-2

Analyze option

If you click on the dropdown arrow on any of the three editors, you will see an option to Analyze your code.

This is a tool that will help you find and fix errors in your code.

analyze-before-option
analyze-after-option

Viewing Options

If you click on Change View, then you can customize the editor layout or switch between the different view options.  

view-options

Using the console

Located at the bottom left hand corner of the Pen is the console. This is a helpful tool for debugging your code.

Screen-Shot-2021-10-29-at-11.56.20-PM
console

When you are creating your Pens, you do not have to include the DOCTYPE, html, head, or body tags. All of that information is already built into the editor.

If you need to add links for the head section such as Font Awesome icons or Google Fonts, then you can add those in the head section of the HTML settings.

Screen-Shot-2021-10-30-at-12.01.52-AM

Adding CSS libraries and frameworks

CodePen has an option in the settings to add CSS libraries and frameworks to your Pens. Some of the libraries and frameworks include Bootstrap, Tailwind CSS, and Bulma.

Screen-Shot-2021-10-30-at-12.05.47-AM

Adding JavaScript libraries and frameworks

In the JavaScript settings, you can add popular libraries and frameworks such as React, Angular, and Vue to your Pens.

Screen-Shot-2021-10-30-at-12.42.49-AM

Sharing your Pens on Social Media

If you want to share your Pens on various blogs and social media sites, then you can click on the Share button located at the bottom right hand corner.

Screen-Shot-2021-10-30-at-1.32.00-AM

Export Pens

If you want to download your work to your computer, then you can use the Export button located at the bottom right hand corner.

Screen-Shot-2021-10-30-at-1.33.45-AM

This will create a folder of all your files.

Screen-Shot-2021-10-30-at-1.35.37-AM

Embed Pens into blogs and articles

If you want to show code examples in your blog posts, then you can embed your CodePen creation in the page using the Embed button. This is located at the bottom right hand corner.

Screen-Shot-2021-10-30-at-1.40.10-AM
Screen-Shot-2021-10-30-at-1.40.28-AM

How to fork a Pen

To fork a Pen means to create a copy of that Pen. When you fork it, you will have access to all of the code and will be able to modify it to your liking.

First go to the Pen you are interested in forking. Then click on the fork button located at the bottom right hand corner.

Screen-Shot-2021-10-30-at-12.36.47-AM

Once you fork the Pen, then it will create a copy for your CodePen account. Make sure to hit the save button and you can start modifying the code from there.

How to add preprocessors and packages to a Pen

In CodePen, you have the option to add HTML, CSS, or JavaScript preprocessors as well as NPM packages to your Pens.

In the HTML settings, you can choose from Haml, Markdown, Slim or Pug.

Screen-Shot-2021-10-30-at-12.46.00-AM

In the CSS settings, you can choose from Less, SCSS, Sass, Stylus or PostCSS.

Screen-Shot-2021-10-30-at-12.46.40-AM

In the JavaScript settings, you can choose from Babel, TypeScript, CoffeeScript or LiveScript.  

Screen-Shot-2021-10-30-at-12.49.01-AM

You can also add NPM packages such as react-bootstrap to your Pens.

Screen-Shot-2021-10-30-at-1.03.50-AM

Basic Features of the Project Editor

If you are working on a project that needs multiple files, then you should consider using the Project editor instead of the Pen editor. For the free account, you are allowed one project.

Templates

There are a few template options for HTML and CSS projects as well as React projects.

Screen-Shot-2021-10-30-at-1.12.17-AM

If you choose to upgrade to the paid subscription, then you will have access to the Tailwind CSS and Bootstrap templates.

Files and Directory

To add a new file or folder, click on the buttons located at the bottom left hand corner.

Screen-Shot-2021-10-30-at-1.18.36-AM
Screen-Shot-2021-10-30-at-1.19.13-AM

You can also upload files from your computer using the drag and drop feature located right above the New File button.

Screen-Shot-2021-10-30-at-1.21.31-AM
Screen-Shot-2021-10-30-at-1.22.29-AM

You can add a total of 10 files to your project. If you need to add more files, then you will have to upgrade to one of the paid packages.

Sharing projects

If you want to share your completed project on social media or blogging platforms, then you can click on the Share button located on the bottom right hand corner.

Screen-Shot-2021-10-30-at-1.26.35-AM

Exporting projects

You can also export your project files and download them to your computer, using the Export button located on the bottom right hand corner.

Screen-Shot-2021-10-30-at-1.28.18-AM

What do you get with the paid subscriptions?

The paid subscription plans offer more CodePen features such as Collab mode, Asset hosting, more templates, and custom domains.

To learn more about the different paid subscription plans, please visit the CodePen PRO page.

Screen-Shot-2021-10-30-at-1.52.42-AM

What are CodePen challenges?

If you want to practice your frontend skills, then you can participate in the monthly challenges. Each month will have a theme, and you will practice skills with a new challenge each week.

Screen-Shot-2021-10-30-at-1.55.29-AM

You will also have access to the previous monthly challenges.

Screen-Shot-2021-10-30-at-1.56.26-AM

I hope you enjoyed this article and best of luck on your frontend developer journey.