Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's 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 it's URL and the proper URL extention.

+ 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

Save Automatically?

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

              
                <!--Prism-->
<link id="import-theme" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/components/prism-core.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/plugins/autoloader/prism-autoloader.min.js"></script>

<!--Code-input is on GitHub ==> https://github.com/WebCoder49/code-input-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.1/code-input.css">
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.1/code-input.js"></script>
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.1/plugins/indent.js"></script>
<script src="https://cdn.jsdelivr.net/gh/WebCoder49/code-input@1.1/plugins/autodetect.js"></script>
<script>
  codeInput.registerTemplate("code-input", codeInput.templates.prism(Prism, [new codeInput.plugins.Indent()]));
</script>

<center>
<h2><code>code-input</code> - <a href="https://github.com/WebCoder49/code-input" target="_blank"><b>View on GitHub</b></a></h2>
<h3><a href="https://github.com/WebCoder49/code-input" target="_blank"><img src="https://img.shields.io/github/v/release/WebCoder49/code-input?label=%20&logo=github&style=for-the-badge" alt="Latest Release"/> <img src="https://img.shields.io/github/license/WebCoder49/code-input?label=%20&logo=github&style=for-the-badge" alt="MIT-licensed"/></a><br/><small><a href="#wysiwyg">WYSIWYG it ⬇️</a></small></h3>
  <header><a href="https://github.com/WebCoder49/code-input/releases/" target="_blank">v1.1</a> is out now, with new plugins for autodetecting languages, and the option to register after creating an element!</header>

<code-input style="resize: both; overflow: hidden; width: 40%;" lang="JavaScript" placeholder="Write some JavaScript!" value="console.log('Hello, World!');
for(let i = 0; i < 10; i++) {
	// Press Enter...
}
// Write some code!"></code-input>
</center>

<p>This is a demo of a custom element for editable, syntax-highlighted code, inspired by a suggestion in a comment! Please see the CSS-Tricks article <a href="https://css-tricks.com/creating-an-editable-textarea-that-supports-syntax-highlighted-code/">here</a>, and the original demo <a href="https://codepen.io/WebCoder49/details/dyNyraq">here</a>.</p>
<p>This could be used for HTML forms where code is submitted, quizzes or code editors, and acts like a normal <code>&lt;textarea&gt;</code> element. Syntax highlighting by Prism.js, and editability by WebCoder49.</p>

<h2>Demo</h2>

<div>
  <label for="select-theme">Theme: </label><select id="select-theme" onchange="document.querySelector('#import-theme').setAttribute('href', this.value);">
    <option value="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism.css">Default</option>
    <option value="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-tomorrow.css">Tomorrow Night (Rosey)</option>
    <option value="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-dark.css">Dark</option>
    <option value="https://cdnjs.cloudflare.com/ajax/libs/prism/1.23.0/themes/prism-funky.css">Funky</option>
  </select> <em>(Static syntax highlighting powered by <a href="prismjs.com">Prism.js</a>)</em>
  <hr/>
  <code-input style="height: 300px; width: 30%; float: left; margin: 1%;" lang="HTML" name="html_code" placeholder="HTML"></code-input>
  <code-input style="height: 300px; width: 30%; float: left; margin: 1%;" lang="CSS" name="css_code" placeholder="CSS"></code-input>
  <code-input style="height: 300px; width: 30%; float: left; margin: 1%;" lang="JavaScript" name="js_code" placeholder="JavaScript"></code-input>
</div>

<hr/>
<h2 id="wysiwyg">Try it out here!</h2>
<div>
  <code-input style="margin: 20px; margin-bottom: 50px;" oninput="document.querySelector('#dynamic-demo').innerHTML = this.value;" lang="HTML" name="html_code" placeholder="<!--This will edit the example below.-->" value="<!--This will edit the example below.-->
<code-input lang=''></code-input>"></code-input>
  <hr/>
  <div id="dynamic-demo" style="margin: 20px; margin-bottom: 50px;">
    <!--This will edit the example below.-->
    <code-input></code-input>
  </div>
  <hr/>
</div>

<h2>Usage</h2>
<p>Please see the <a href="https://github.com/WebCoder49/code-input">GitHub README</a>. </p>
<script>codeInput.registerTemplate("code-input", codeInput.templates.prism(Prism));</script>
              
            
!

CSS

              
                /* Please see GitHub link */

body {
  font-family: "Lato", sans-serif;
}

header {
  background-color: beige;
  color: #400;
  text-align: center;
  font-size: 120%;
  
  padding: 10px;
  border-radius: 10px;
  margin: 10px;
  width: 100%;
  max-width: 500px;
}
              
            
!

JS

              
                /* Please see GitHub link */
              
            
!
999px

Console