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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <header role="banner">
    <h1>Log in</h1>
</header>

<main role="main">

    <form id="login-form" action="index.html" method="post">
        <dl>
            <dt><label for="login-email">Email address</label></dt>
            <dd>
                <input type="email" name="login-email" id="login-email" placeholder="name@domain.com" />
                <span id="email-error" class="error-msg">Please insert a email address</span>
            </dd>

            <dt><label for="login-password">Password</label></dt>
            <dd>
                <input type="password" name="login-password" id="login-password" placeholder="Your Password" />
                <span id="password-error" class="error-msg">Please insert a password</span>
            </dd>
        </dl>
        <p><input type="submit" name="login-submit" id="login-submit" value="Log In" /></p>
    </form>

</main>

<footer role="contentinfo">
    <p>Lorem ipsum dolor sit amet... &copy; 2016</p>
</footer>

              
            
!

CSS

              
                @mobile-breakpoint 		: 480;
@desktop-breakpoint 	: 860;
@mobile 	: ~"all and (max-width: @{mobile-breakpoint}px)";
@non-mobile : ~"all and (min-width: @{mobile-breakpoint}px)";
@tablet 	: ~"all and (min-width: @{mobile-breakpoint}px) and (max-width: @{desktop-breakpoint}px)";
@desktop 	: ~"all and (min-width: @{desktop-breakpoint}px)";


@color-primary : #f7ad0b;
@color-primary-darker : #f3741b;
@global-margin: 3rem;


html, body {
	margin: 0;
	padding: 0;
}
html {
	font-family: sans-serif;
	-ms-text-size-adjust: 100%;
	-webkit-text-size-adjust: 100%;
	box-sizing: border-box;
	font-size: 62.5%;
}
body {
	font-size: 1.6em;
	line-height: 1.5;
}
*, *:before, *:after {
	box-sizing: inherit;
    -webkit-transition: all 0.25s ease-out;
	transition: all 0.25s ease-out;
}
footer, header, main {
	display: block;
}
a {
	text-decoration: none;
	border-bottom: solid transparent 1px;
}
a:active, a:hover { outline: 0; }
b, strong { font-weight: bold; }
small { font-size: 80%; }

input {
	font: inherit;
	margin: 0;
    line-height: normal;
}
button::-moz-focus-inner,
input::-moz-focus-inner {
	border: 0;
	padding: 0;
}
dl {
	dt, dd {
		margin: 0;
		padding: 0;
	}
}


// ++++++++++ //


html {
    min-height: 100%;
    background-image: -moz-linear-gradient(-60deg, @color-primary 0%, @color-primary-darker 80%);
	background-image: -webkit-linear-gradient(-60deg, @color-primary 0%, @color-primary-darker 80%);
	background-image: linear-gradient(120deg, @color-primary 0%, @color-primary-darker 80%);
	color: #fff;
}
body {
    font-family: 'Montserrat', sans-serif;
    width: 90%;
    margin: 0 auto;
}
body > * {
	font-size: 1.4rem;
	font-weight: 400;
    text-shadow: 0 -1px 0 fade(@color-primary-darker, 75%);
}
header, footer {
    p, h1 {
        margin: 0;
        padding: @global-margin 0;
        color: rgba(255, 255, 255, .8);
    }
    h1 {
    	font-weight: 400;
        font-size: 2.6rem;
        letter-spacing: -.05rem;
    }
}
header {
    border-bottom: dotted lighten(@color-primary, 10%) 1px;
}
footer {
    border-top: dotted lighten(@color-primary, 10%) 1px;
}
main {
    padding: @global-margin 0;

    form {

        label {
            display: block;
            text-transform: uppercase;
            letter-spacing: 1px;
            padding: 1rem 0 .5rem 0;
        }

        // input
        input[type="email"],
        input[type="password"] {
        	-webkit-appearance: none;
        	-moz-appearance: none;
        	appearance: none;
        	border-radius: 4px;
        	display: inline-block;
        	vertical-align: top;
        	padding: .5rem 1rem;
            height: 4.6rem;
        	width: 100%;

            border: solid @color-primary 1px;
            border-top: solid @color-primary-darker 1px;
            background: rgba(255, 255, 255, .9);
				color: #333;
		 }
        input[type="email"]:focus,
        input[type="password"]:focus {
        	outline: 0;
            border: solid @color-primary-darker 1px;
            background: rgba(255, 255, 255, 1);
        }

        // button
        input[type="submit"] {
        	cursor: pointer;
        	display: inline-block;
        	text-transform: uppercase;
        	font-weight: 700;
        	letter-spacing: .5rem;
        	text-align: center;
        	white-space: nowrap;
        	vertical-align: top;
        	padding: 0;
        	height: 4.6rem;
        	line-height: 4.6rem;
            border-radius: 4px;
            width: 100%;

            background: rgba(255, 255, 255, .01);
            color: lighten(@color-primary, 35%);
            border: solid @color-primary 1px;
            box-shadow: 0 0 0 2px fade(darken(@color-primary-darker, 15%), 15%);
            font-size: 90%;
            text-shadow: 0 -1px 0 rgba(0, 0, 0, .25);
        }
        input[type="submit"]:hover, input[type="submit"]:focus {
            color: #fff;
            background: @color-primary;
            border: solid @color-primary 1px;
        	outline: 0;
        }



        // form

        width: 100%;
        max-width: 48rem;
        margin: 0 auto;

        input {
            width: 100%;
            max-width: 48rem;
        }

        @media @desktop {

            max-width: 70rem;

            dl {
                overflow: auto;

                dt {
                    float: left;
                    clear: left;
                    width: 22rem;
                    text-align: right;
                    label {
                        padding: 0 2rem 0 0;
                        line-height: 4.6rem;
                    }
                    padding: 0 0 @global-margin/2 0;
                }
                dd {
                    float: left;
                    width: 48rem;
                    padding: 0 0 @global-margin/2 0;
                }
            }
            p {
                padding-left: 22rem;
            }

        }

    }

}

.error-msg {
    display: block;
    color:#c00;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .25);
    overflow: hidden;

    margin: 0;
    height: 0;

    &.open {
        margin: .5rem 0 0 0;
        height: auto;
    }
}

              
            
!

JS

              
                // Utils
function addclass(el, classname) {
	if (el.classList) {
		el.classList.add(classname);
	} else {
		el.className += ' ' + classname;
	}
}
function removeclass(el, classname) {
	if (el.classList) {
		el.classList.remove(classname);
	} else {
		el.className = el.className.replace(new RegExp('(^|\\b)' + classname.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
	}
}

// Validate
var FormValidator = {

    the_email : document.querySelector('#login-email'),
    the_password : document.querySelector('#login-password'),

    check : function() {

        if (this.the_password.value === '' || this.the_email.value === '') {

            // Password
            if (this.the_password.value === '') {
                addclass(document.querySelector('#password-error'), 'open');
                this.the_password.focus();
            } else {
                removeclass(document.querySelector('#password-error'), 'open');
            }

            // Mail
            if (this.the_email.value === '') {
                addclass(document.querySelector('#email-error'), 'open');
                this.the_email.focus();
            } else {
                removeclass(document.querySelector('#email-error'), 'open');
            }
            return false;

        } else {

            return true;
        }
    },

    clear : function() {

        removeclass(document.querySelector('#email-error'), 'open');
        removeclass(document.querySelector('#password-error'), 'open');

        // Done... output something...
        window.alert('all good : \n - Email : ' + this.the_email.value + '\n - Pass : '+ this.the_password.value);
        this.the_email.value = '';
        this.the_password.value = '';
    },

    init : function() {
        var that = this;
        document.querySelector('#login-form').onsubmit = function(e) {
            e.preventDefault();
            if ( that.check() ) {
                that.clear();
            }
        }
    }
}

// Init
FormValidator.init();

              
            
!
999px

Console