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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div id="app">
<pre id="login-codes">
&lt;!DOCTYPE html>
  &lt;html>
    &lt;head>
        &lt;meta charset="utf-8" />
        &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
        &lt;link rel="icon" type="image/png" href="/assets/img/favicon.png">
        &lt;title>Login&lt;/title>
        &lt;link rel="stylesheet" type="text/css" href="/assets/css/main.css"/>
    &lt;/head>
    &lt;body>
          
        &lt;header>
          &lt;div class="header__logo">
            &lt;a href="/">
              &lt;img src="assets/img/logo.svg">
            &lt;/a>
          &lt;/div>
        &lt;/header>
           
        &lt;main>
          &lt;h1>LOGIN&lt;/h1>
          &lt;form>
              
            &lt;input type="text" placeholder="username" value="<span id="username" contenteditable> </span>">
            &lt;input type="password" placeholder="password" value="<span id="password" contenteditable> </span>">
            &lt;button type="submit"><span id="loginButton" style="cursor:pointer;">Login</span>&lt;/button>
            <span id="formAlert" style="display:none;">&lt;p>Please fill out the form.&lt;/p></span>
          &lt;/form>
        &lt;/main>
          
          
        &lt;footer>
          &lt;p>copyright © &lt;span id="year">&lt;/span>&lt;/p>
        &lt;/footer>
          
        &lt;script>
          var year = new Date().getFullYear();
          document.getElementById("year").innerHTML = year;
        &lt;/script>
        &lt;script src="/assets/js/main.js">&lt;/script>
        
    &lt;/body>
&lt;/html>
</pre>
  
  
  
  
  
<pre id="redirect-codes" style="display:none;">
&lt;!DOCTYPE html>
    &lt;html>
      &lt;head>
          &lt;meta charset="utf-8" />
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
          &lt;link rel="icon" type="image/png" href="/assets/img/favicon.png">
          &lt;title>Redirecting...&lt;/title>
          &lt;link rel="stylesheet" type="text/css" href="/assets/css/main.css"/>
      &lt;/head>
    &lt;body>
          
      &lt;p>Redirecting.... &lt;/p>
          
    &lt;/body>
&lt;/html>
</pre>

  
  
  
  
<pre id="page-codes" style="display:none;">
&lt;!DOCTYPE html>
    &lt;html>
      &lt;head>
          &lt;meta charset="utf-8" />
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
          &lt;link rel="icon" type="image/png" href="/assets/img/favicon.png">
          &lt;title>Home Page&lt;/title>
          &lt;link rel="stylesheet" type="text/css" href="/assets/css/main.css"/>
      &lt;/head>
    &lt;body>
          
        &lt;header>
          &lt;div class="header__logo">
            &lt;a href="/">
              &lt;img src="assets/img/logo.svg">
            &lt;/a>
          &lt;/div>
          &lt;div class="header__profile">
            &lt;p><span id="usernameHeaderProfile"></span>&lt;</span>/p>
          &lt;/div>
       &lt;/header>
            
       &lt;main>
           &lt;h1>WELCOME&lt;/h1>
           &lt;p> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod 
           tempor incididunt ut labore et dolore magn. &lt;/p>
       &lt;/main>
            
  
       &lt;footer>
          &lt;p>copyright © &lt;span id="year">&lt;/span>&lt;/p>
       &lt;/footer>
  
       &lt;script>
          var year = new Date().getFullYear();
          document.getElementById("year").innerHTML = year;
       &lt;/script>
       &lt;script src="/assets/js/main.js">&lt;/script>
  
  &lt;/body>
&lt;/html> 
</pre>

</div>



              
            
!

CSS

              
                * 
  padding 0 
  margin 0
              
            
!

JS

              
                const loginCodes = document.getElementById("login-codes");
const redirectCodes = document.getElementById("redirect-codes");
const pageCodes = document.getElementById("page-codes");
const loginButton = document.getElementById("loginButton");
const username = document.getElementById("username");
const password = document.getElementById("password");
const formAlert = document.getElementById("formAlert");
const usernameHeaderProfile = document.getElementById("usernameHeaderProfile");

loginButton.addEventListener("click", function() {
  formAlert.style.display = "inline-block";
  if(username.textContent.length > 2 && password.textContent.length > 2){
     formAlert.style.display = "none";
     
     loginCodes.style.display = "none";
     redirectCodes.style.display = "block";
     setTimeout(function(){
       redirectCodes.style.display = "none";
       pageCodes.style.display = "block";
       usernameHeaderProfile.textContent = username.textContent.trim();
     }, 1000);
  }
});
              
            
!
999px

Console