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

              
                <button onClick="beforebegin()" class="red" id="bb">①element外(前)</button>
<button onClick="afterbegin()" class="blue" id="ab">②element内(前)</button>
<button onClick="beforeend()" class="green" id="be">③element内(後)</button>
<button onClick="afterend()" class="yellow" id="ae">④element外(後)</button>
<p>
    <!-- ①element外(前) -->
    <span id="main">
        <!-- ②element内(前) -->
        本文
        <!-- ③element内(後) -->
    </span>
    <!-- ④element外(後) -->
</p>
              
            
!

CSS

              
                .red { background-color:rgba(255,0,0,0.3); }
.blue { background-color:rgba(0,0,255,0.3); }
.green { background-color:rgba(0,128,0,0.3); }
.yellow { background-color:rgba(255,255,0,0.3); }
              
            
!

JS

              
                // 対象要素
var main = document.getElementById('main');
// ①element外(前)用
function beforebegin(){
    main.insertAdjacentHTML('beforebegin', '<span class="red">タブ外先頭</span><br>');
}
// ②element内(前)用
function afterbegin(){
    main.insertAdjacentHTML('afterbegin', '<span class="blue">タブ内先頭</span><br>');
}
// ③element内(後)用
function beforeend(){
    main.insertAdjacentHTML('beforeend', '<br><span class="green">タブ内末尾</span>');
}
// ④element外(後)用
function afterend(){
    main.insertAdjacentHTML('afterend', '<br><span class="yellow">タブ外末尾</span>');
}
              
            
!
999px

Console