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.


                <div class="movie">
  <button type="button" class="star"><span>&#9733;</span></button>
  <h1>The NeverEnding Story</h1>
  <img class="movie__image" src=",0,640,1000_AL_.jpg" alt="The NeverEnding Story">


                .movie {
  position: relative;
  cursor: pointer;
  background-color: magenta;
  width: 30%;
  padding: 12px;
  .movie__image {
    width: 80%;
    display: block;
    margin: 0 auto;

.star {
  font-size: 20px;
  font-weight: bold;
  border: 2px solid black;
  background-color: white;
  cursor: pointer;


** Ejemplo de dos elementos anidados
** con dos eventos del mismo tipo (click)
** Cuando ocurre el que se encuentra anidado
** evitamos que ocurra el de la madre
** El reto es conseguir que cuando
** se haga click en la estrella ocurra una cosa
** y cuando se haga click en el div '.movie'
** suceda otra
const movie = document.querySelector('.movie');
const movieStar = document.querySelector('.star');

function handleMovieClick(e) {
  const clickedElement =;
  ** Si el elemento sobre el que se ha hecho click
  ** esta dentro de una etiqueta '.star'
  ** o es una etiqueta '.star' 
  if(clickedElement.closest('.star')) {
    // no hacemos nada --> return false;
    return false;
  console.log('MOVIE CLICK EVENT: open modal with detail');

function handleMovieStarClick(e) {
  console.log('STAR CLICK EVENT: change star style');

movie.addEventListener('click', handleMovieClick);
movieStar.addEventListener('click', handleMovieStarClick);