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

              
                <!-- :valid -->
<section class="example-cntr validation valid">
    <h1>CSS <code>:valid</code> pseudo-class</h1>
    <p>The <code>:valid</code> pseudo-class targets form elements whose formatting is correct according to that element’s required format.</p>
    <p>In the following example, when the email input field has an email structure formatted correctly, the field it’s considered “valid” and a <span class="green">green</span> border appears around the input.</p>
    <p><em><span class="underline">Note:</span> In its default state, the field is considered valid. Not sure about you, but to me that feels counterintuitive :p</em></p>
    <label>
        <span>Email:</span>
        <input type="email" id="email" placeholder="name@domain.com">
    </label>
</section>

<!-- :invalid -->
<section class="example-cntr validation invalid">
    <h1>CSS <code>:invalid</code> pseudo-class</h1>
    <p>The <code>:invalid</code> pseudo-class targets form elements whose formatting isn’t correct according to that element’s required format.</p>
    <p>In the following example, when the email input field has an incorrectly formatted email structure it’s automatically invalid and a <span class="red">red</span> border appears around the input.</p>
    <label>
        <span>Email:</span>
        <input type="email" id="email" placeholder="name@domain.com">
    </label>
</section>

              
            
!

CSS

              
                //'validations' generic styles
.validation {
    input[type=email] {
        box-sizing: content-box;
        width: 200px;
        padding: 0 5px;
        border: #666 5px solid;
        border-radius: 2px;
        cursor: text;
        transition: .5s;
    }
    label { display: inline-block; }
    span {
        display: block;
        margin-bottom: 5px;
    }
}

//:valid
.valid {
    input[type=email]:valid { border-color: $g; }
}
//:invalid
.invalid {
    input[type=email]:invalid { border-color: $r; }
}



//Styling stuff not needed for demo
body {
    text-align: left;
    line-height: 1.5;
}
h1 {
    font-size: 24px;
    text-transform: none;
    border-bottom: #636363 1px dotted;
    code {
        display: inline-block;
        margin-bottom: 10px;
        color: $y;
        background: none;
        box-shadow: none;
    }
}
code { font-size: 1em; }
input {
    width: 30px; height: 30px;
    vertical-align: middle;
    outline: none;
}
input, label { cursor: pointer; }
input[type=text],
input[type=email] { width: 100%; }

label {
    padding: 3px 8px 5px;
    border-radius: 2px;
    border: transparent 1px solid;    
    transition: .5s;
    &:hover {
        border: rgba(white,.2) 1px solid;        
    }
}
.example-cntr {
    max-width: 800px;
    margin: 0 auto 50px;
    padding: 30px;
    box-shadow: 0 1px 2px rgba(black,.3);
    background: rgba(black,.15);
}
.flex-ctnr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

span {
    &.red,
    &.green,
    &.yellow {
        display: inline-block;
        font-weight: bold;
        font-size: 18px;
        text-shadow: 0 1px 0 #000;
    }
}
.underline { text-decoration: underline; }
.red { color: $r; }
.green { color: $g; }
.yellow { color: $y; }
              
            
!

JS

              
                
              
            
!
999px

Console