Pen Settings



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


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


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.


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.


                <div id="editable" contenteditable="true"></div>



                body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;

#editable {
  width: 500px;
  min-height: 350px;
  padding: 12px;
  border: 1px solid #eee;
  border-radius: 4px;
  box-shadow: 0px 0px 5px #ddd;
#editable:after {
  content: "請在這裡輸入文字...";
  color: #7e7e7e;
#editable:focus:after {
  display: none;
#editable:not(:empty):after {
  display: none;


                const editableDiv = document.querySelector("#editable");

window.addEventListener("popstate", function (e) {
  editable.textContent = "";
  if (e.state && e.state.text) {
    // 每次有歷史紀錄的「移動」時,便將當下紀錄的 state 丟到可編輯元素中
    editable.textContent = e.state.text;

editableDiv.addEventListener("input", function () {
  // 每次輸入時新增一筆歷史紀錄,且會利用 state 儲存當下的輸入內容
  window.history.pushState({ text: editable.textContent }, null);