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

              
                <p>A simple test to help me understand last-of-type pseudo-selector.</p>

<p>I've read...</p>

<blockquote>
<p>':last-of-type matches an element which is the last element of its type (tag) within its (first-level) parent. It doesn't apply to classes.'</p>
</blockquote>

<hr />

<strong>Here's a div, with no class.</strong>

<div>
<p>Paragraph 1.</p>
<p>Paragraph 2. (Should be red.)</p>
</div>

<em>The color is correctly applied, because paragraph 2 is the last p in its parent (div).</em>

<hr />

<strong>Here's another div, with a class (test).</strong>

<div class="test">
<p>Paragraph 3.</p>
<p>Paragraph 4. (Should be green.)</p>
</div>

<em>The correct color is applied, suggesting last-of-type can be applied to a class.</em>

<hr />

<strong>Here's another div, with a different class (test2).</strong>

<div class="test2">
<p>Paragraph 5.</p>
<p>Paragraph 6. (Should be blue.)</p>
</div>

<em>The correct color is applied - suggesting last-of-type can be applied to a specific class.</em>

<hr />

<strong>And now two paragraphs, not in divs.</strong>

<p class="test">Paragraph 7.</p>
<p class="test">Paragraph 8. (Should be yellow.)</p>

<em>The correct color is applied.</em>

<hr />

This seems to suggest that last-of-type can also target a class... which seems logical.
              
            
!

CSS

              
                body
{
max-width: 500px;  
}

div p:last-of-type
{
color: red;
}

div.test p:last-of-type
{
color: green;
}

div.test2 p:last-of-type
{
color: blue;
}

p.test:last-of-type
{
color: yellow;
}
              
            
!

JS

              
                
              
            
!
999px

Console