Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
  <meta charset="utf-8" />
  <title>React from CDN</title>
  <style>/* moved to CSS panel */</style>
</head>

<body>
  <!-- Target container -->
  <div id="app"></div>

  <!-- React --><!-- ReactDOM -->
  <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js">
  </script>

<!-- Our own custom React code is now in the JS panel -->
              
            
!

CSS

              
                .cars {
  display: flex;
  flex-wrap: wrap;
}
.car {
  border: 1px solid gray; 
  margin: 20px; 
  padding: 20px;
  width: 300px;
}
.car img {
  width: 100%;
}
              
            
!

JS

              
                function Cars() {
  return (
    <div className="cars">
      <div className="car">
        <img src="https://www.codingexercises.com/img/2022-01-25/001-bmw-blue.jpg" />
        <h2>My BMW</h2>
        <p>
          My BMW is blue.
        </p>
        <p>It's a bit older, from 2011.</p>
      </div>
      <div className="car">
        <img src="https://www.codingexercises.com/img/2022-01-25/002-mercedes-gray.jpg" />
        <h2>My Mercedes</h2>
        <p>
          My Mercedes is gray.
        </p>
        <p>It's a bit newer, from 2018.</p>
      </div>
      <div className="car">
        <img src="https://www.codingexercises.com/img/2022-01-25/003-toyota-gray.jpg" />
        <h2>My Toyota</h2>
        <p>
          My Toyota is gray.
        </p>
        <p>It's brand new.</p>
      </div>
      <div className="car">
        <img src="https://www.codingexercises.com/img/2022-01-25/004-alpha-romeo-red.jpg" />
        <h2>My Alpha Romeo</h2>
        <p>
          My Alpha Romeo is red.
        </p>
        <p>It's a bit older, from 2012.</p>
      </div>
    </div>
  );
}

let app = (
  <div>
    <Cars />
  </div>
);

ReactDOM.render(app, document.querySelector("#app"));
              
            
!
999px

Console