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

              
                <input type="radio" name="a-0" class="correct" id="a-0-c" /><input type="radio" name="a-0" id="a-0-i-0" /><input type="radio" name="a-0" id="a-0-i-1" /><input type="radio" name="a-0" id="a-0-i-2" />
<input type="radio" name="a-1" class="correct" id="a-1-c" /><input type="radio" name="a-1" id="a-1-i-0" /><input type="radio" name="a-1" id="a-1-i-1" /><input type="radio" name="a-1" id="a-1-i-2" />
<input type="radio" name="a-2" class="correct" id="a-2-c" /><input type="radio" name="a-2" id="a-2-i-0" /><input type="radio" name="a-2" id="a-2-i-1" /><input type="radio" name="a-2" id="a-2-i-2" />
<input type="radio" name="a-3" class="correct" id="a-3-c" /><input type="radio" name="a-3" id="a-3-i-0" /><input type="radio" name="a-3" id="a-3-i-1" /><input type="radio" name="a-3" id="a-3-i-2" />
<input type="radio" name="a-4" class="correct" id="a-4-c" /><input type="radio" name="a-4" id="a-4-i-0" /><input type="radio" name="a-4" id="a-4-i-1" /><input type="radio" name="a-4" id="a-4-i-2" />

<div id="results" class="box">
  <div class="results"><span id="result"></span> correct answers</div>
  <p><a href="#">Restart the game</a></p>
  <div>CSS Trivia developed by Alvaro Montoro</div>
</div>

<div class="options box" id="q-4">
  <div class="question">How many lines of JavaScript code are there in this web game?</div>
  <label for="a-4-c">0</label>
  <label for="a-4-i-0">About 3.50</label>
  <label for="a-4-i-1">42</label>
  <label for="a-4-i-2">734</label>
  <a href="#results">Complete Test</a>
</div>

<div class="options box" id="q-3">
  <div class="question">Can a trivia game be developed only using HTML and CSS (no JS)?</div>
  <label for="a-3-c">Yes</label>
  <label for="a-3-i-0">No</label>
  <label for="a-3-i-1">Maybe</label>
  <label for="a-3-i-2">Inconceivable</label>
  <a href="#q-4">Confirm Answer</a>
</div>

<div class="options box" id="q-2">
  <div class="question">Which of these selectors is correct?</div>
  <label for="a-2-i-0">#class</label>
  <label for="a-2-i-1">.id</label>
  <label for="a-2-i-2">Both are wrong</label>
  <label for="a-2-c">Both are correct</label>
  <a href="#q-3">Confirm Answer</a>
</div>

<div class="options box" id="q-1">
  <div class="question">What does CSS stand for?</div>
  <label for="a-1-i-0">CSS Style Sheet</label>
  <label for="a-1-c">Cascading Style Sheet</label>
  <label for="a-1-i-1">Casual Style Sheet</label>
  <label for="a-1-i-2">Classy Style Sheets</label>
  <a href="#q-2">Confirm Answer</a>
</div>

<div class="options box" id="q-0">
  <div class="question">What year was CSS first released?</div>
  <label for="a-0-i-0">1988</label>
  <label for="a-0-i-1">1992</label>
  <label for="a-0-c">1996</label>
  <label for="a-0-i-2">2000</label>
  <a href="#q-1">Confirm Answer</a>
</div>

<div class="box" id="welcome">
  <h2>CSS Trivia</h2>
  <p>Welcome to CSS Trivia! A small Q&A game developed exclusively with HTML and CSS, and not a single line of JavaScript</p>
  <a href="#q-0">Start Game</a>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Dosis|Roboto');

body {
  counter-reset: correct;
}
body input.correct:checked {
  counter-increment: correct;
}
body #results #result::before {
  content: counter(correct);
}

html,
body {
  overflow: hidden;
  user-select: none;
  background: linear-gradient(#99ccff, #6699cc);
  font-family: Dosis, Roboto, sans-serif;
  position: relative;
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

.box {
  background: white;
  border-radius: 3px;
  padding: 1em;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(50%, -50%);
  -webkit-transform: translate(50%, -50%);
  -moz-transform: translate(50%, -50%);
  width: 400px;
  z-index: 0;
  opacity: 0;
  transition: all 1s;
  box-shadow: 0 1.5em 0.5em -1em rgba(0, 0, 0, 0.25);
}

#welcome,
.box:target {
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
  -moz-transform: translate(-50%, -50%);
  z-index: 1;
  opacity: 1;
}

#q-0:target ~ #welcome,
#q-1:target ~ #welcome,
#q-2:target ~ #welcome,
#q-3:target ~ #welcome,
#q-4:target ~ #welcome,
#results:target ~ #welcome,
#q-1:target ~ #q-0,
#q-2:target ~ #q-1,
#q-3:target ~ #q-2,
#q-4:target ~ #q-3,
#results:target ~ #q-4 {
  transform: translate(-200%, -50%);
  opacity: 0;
}

label,
.box > a {
  background: linear-gradient(#336699, #003366);
  width: 49%;
  margin: 0.5%;
  margin-bottom: 0.5%;
  display: block;
  float: left;
  border-radius: 2px;
  padding: 0.33em;
  box-sizing: border-box;
  border: 1px solid #003366;
  color: white;
  cursor: pointer;
  font-size:0.9em;
}

label:hover {
  background: linear-gradient(#225588, #002255);
}

label::before {
  padding-right: 0.33em;
  margin-right: 0.33em;
  border-right: 1px solid rgba(0, 0, 0, 0.3);
}

label:nth-child(2)::before {
  content: "A";
}
label:nth-child(3)::before {
  content: "B";
}
label:nth-child(4)::before {
  content: "C";
}
label:nth-child(5)::before {
  content: "D";
}

#a-0-c:checked ~ #q-0 [for="a-0-c"],
#a-0-i-0:checked ~ #q-0 [for="a-0-i-0"],
#a-0-i-1:checked ~ #q-0 [for="a-0-i-1"],
#a-0-i-2:checked ~ #q-0 [for="a-0-i-2"],
#a-1-c:checked ~ #q-1 [for="a-1-c"],
#a-1-i-0:checked ~ #q-1 [for="a-1-i-0"],
#a-1-i-1:checked ~ #q-1 [for="a-1-i-1"],
#a-1-i-2:checked ~ #q-1 [for="a-1-i-2"],
#a-2-c:checked ~ #q-2 [for="a-2-c"],
#a-2-i-0:checked ~ #q-2 [for="a-2-i-0"],
#a-2-i-1:checked ~ #q-2 [for="a-2-i-1"],
#a-2-i-2:checked ~ #q-2 [for="a-2-i-2"],
#a-3-c:checked ~ #q-3 [for="a-3-c"],
#a-3-i-0:checked ~ #q-3 [for="a-3-i-0"],
#a-3-i-1:checked ~ #q-3 [for="a-3-i-1"],
#a-3-i-2:checked ~ #q-3 [for="a-3-i-2"],
#a-4-c:checked ~ #q-4 [for="a-4-c"],
#a-4-i-0:checked ~ #q-4 [for="a-4-i-0"],
#a-4-i-1:checked ~ #q-4 [for="a-4-i-1"],
#a-4-i-2:checked ~ #q-4 [for="a-4-i-2"] {
  background: linear-gradient(#ffee66, #ccbb33);
  border: 1px solid #ccbb33;
  color: #333333;
}

.box h2,
.box .question,
#results > div.results {
  margin: 0;
  padding: 0;
  font-size: 1.4em;
  font-weight: bold;
  margin-bottom: 1em;
}

.box > a {
  float: right;
  margin-top: 1em;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(#33dd66, #00aa33);
  border: 1px solid #00aa33;
  color: #ffffff;
  cursor: pointer;
}

.box > a:hover {
  background: linear-gradient(#22cc55, #009922);
}

#results {
  text-align: center;
}

input {
  position: absolute;
  top: -1000px;
}

              
            
!

JS

              
                
              
            
!
999px

Console