Pen Settings



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


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


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.


                <main class="main">
  <section class="jogo">
    <h1>Jogo de Adivinha</h1>
    <div class="status" id="status"> Adivinhe o número sorteado </div>
    <div class="tentativa" id="tentativa">Tentativa: 0</div>
    <form class="form" id="form">
      <label for="chute">Chute um número entre 0 e 100</label>
      <input type="number" name="chute" id="chute"/>
      <button id="btnVerifica">Verificar</button>


                @import url(",400i,700");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;

body {
  font-family: Lato, sans-serif;
  font-size: 20px;

.main {
  background-color: #F8F88D;

.jogo {
  min-height: 100vh;

.jogo, .form{
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

.form label,
.form button {
  margin-top: 1em;

.form input,
.form button {
  font-size: inherit;
  font-family: inherit;
  padding: 0.5em;

.form button {
  background-color: #FBEFFF;
  cursor: pointer;
  border-radius: 0.3em;
  width: 50%;

.form button:hover {
  filter: opacity(0.8);



                // JS

const jogoAdivinha = {
  semente: 100,
  tentativa : 0,
  numeroSorteado : function geraValorAleatorio() {
    return Math.round(Math.random() * this.semente);

const btnVerifica = document.getElementById('btnVerifica');
const status = document.getElementById('status');
const tentativa = document.getElementById('tentativa');

let numeroSorteado = jogoAdivinha.numeroSorteado();

function atualizarTentativa(tentativa, valor) {
  if (valor > 1) {
    tentativa.innerHTML = 'Tentativas : <span style="color: blue">' +
      valor + '</span>';
  } else {
    tentativa.innerHTML = 'Tentativa : <span style="color: blue">' +
      valor + '</span>';

const formAdivinha = document.getElementById('form');

formAdivinha.addEventListener('submit', function(event) {

  const chute = document.getElementById('chute').value;

  if (!!chute == false) {
    status.innerHTML =  '<span style="color:#FF3D00">Digite algum valor</span>';

  atualizarTentativa(tentativa, ++jogoAdivinha.tentativa);

  if (numeroSorteado == chute) {
    status.innerHTML = '<span style="color:#00C853">Parabéns, você acertou!!</span>';
    btnVerifica.hidden = true;
  } else if (numeroSorteado > chute) {
    status.innerText =  'O número sorteado é maior';
  } else if (numeroSorteado < chute) {
    status.innerText =  'O número sorteado é menor';