On October 17, I hosted a workshop at devFest Nantes entitled “The Invasion of Mutant HTML”.
A workshop must by definition involve the participants, I chose to create a mini-game as support. It's a static site available online, open-sourced on GitHub — so you can improve it!
When I say static, I mean static: the repository has a single dependency, server, responsible for providing a basic HTTP server for working locally and server itself has no dependencies. The rest is just HTML, CSS and JavaScript.
It allowed me to get back to basics and considerably gain efficiency; but above all… discover a whole bunch of tips and tricks!
Game mechanics
When you start the game, you will start by customizing your character. The sole objective of this step is to discover the visual structure of a level, allowing you to get personally involved in the game. The chosen values will be applied as soon as possible to all the characters in the game, in a sort of mirror representation .
After choosing your character, a training level familiarizes you with the very simple mechanics of the game: a portion of code to complete and submit, executed live, which affects the area gradually invaded by mutants! This code is in most levels the options passed to a mutationObserver, but sometimes also in the callback function.
In case of failure or success, a modal window will inform you. Let’s talk about this modal window!
The particularities of
I talked about it in 2022 at Paris Web then at devFest Nantes in my topic “Discover “good HTML” and save JS and CSS”, the
In the workshop, I use it in several places:
- to display the game rules in the home screen;
- to interrupt a level, when the number of mutants exceeds a hundred;
- to notify of a failure when submitting code that doesn't work;
- to inform of success, otherwise — and allow progression to the next level.
Open window
Most are opened programmatically, in response to an event. Nothing could be simpler: just retrieve a reference to the
document.querySelector('dialog').showModal();
Without external JavaScript
One exception however, to avoid adding an unnecessary event listener: the game rules window is invoked using an HTML onclick event handler:
<button type="button" onclick="rules.showModal()">Règles du jeu</button> <dialog> <h5> Aparté : la projection des identifiants HTML en objets globaux </h5> <p>Dans cet exemple, j’invoque l’ouverture de la fenêtre modale avec rules.showModal(), sans avoir défini la variable rules. Comment est-ce possible ? En résumé, tout élément porteur d’un attribut id devient mécaniquement une propriété globale de l’objet window, et devient donc accessible directement par son nom. C’est spécifié sous le joli nom de Named Access on Window Object (en anglais).</p> <p>C’est drôlement pratique, non ? Figurez-vous que c’est aussi un vecteur d’attaque méconnu faisant partie d’un groupe sobrement intitulé DOM clobbering (en anglais). Je vous encourage à parcourir les recommandations de l’OWASP pour mitiger le DOM clobbering (en anglais).</p> <h4> Accessibilité </h4> <p>La méthode showModal() permet d’ouvrir une fenêtre modale, pas une simple boîte de dialogue — en respectant les exigences en matière d’accessibilité : la focus est mécaniquement piégé dedans, la fermeture est possible avec la touche <kbd>Échap</kbd>, etc.</p> <h3> L’arrière-plan </h3> <p>Une fois la fenêtre modale ouverte, on peut s’appliquer à la styler. Là où moult bibliothèques de composants imposent une </p> <div> (voire plusieurs) pour servir d’arrière-plan à la fenêtre, la version native est livrée avec un pseudo-élément ::backdrop qui s’étend naturellement sur tout le viewport et est promue, avec la fenêtre modale, par-dessus le reste de la page dans ce qui est spécifié sous le nom de top layer. <p>Vous n’avez plus qu’à lui appliquer une couleur, une opacité ou que sais-je encore. Dans le jeu, j’ai utilisé une propriété au nom évocateur de backdrop-filter pour appliquer un effet de flou grisé sur l’arrière-plan.<br> </p> <pre class="brush:php;toolbar:false">dialog::backdrop { backdrop-filter: grayscale(50%) blur(.25rem); }
Dimensions
Not having mastered the game viewing mode, I used a bit of modern CSS for the width of the modal window so that it had a fluid width, but with minimum and maximum values.
dialog { max-inline-size: clamp(50vw, 100%, 67.5rem); }
The max-inline-size property is the logical property corresponding to max-width in the case of French. And the clamp() function is a little gem, which I already abuse copiously in chaarts (in English) to obtain a pseudo-Boolean in CSS based on a value, as explained on slide 27 of my conference “Draw me a graphic (in CSS)” given at devFest Nantes 2023, TNT #24 and DevQuest 2024.
Close window
I mentioned the ability to close the modal with the Esc key, but the
This is why the dialog value is added to the form submission method. It does not correspond to an HTTP method like get or post, but to an HTML context, and allows you to directly close the parent modal window. It’s very simple to use:
The above is the detailed content of The tips behind the 'Mutant HTML Invasion”. For more information, please follow other related articles on the PHP Chinese website!

I got this question the other day. My first thought is: weird question! Specificity is about selectors, and at-rules are not selectors, so... irrelevant?

Yes, you can, and it doesn't really matter in what order. A CSS preprocessor is not required. It works in regular CSS.

You should for sure be setting far-out cache headers on your assets like CSS and JavaScript (and images and fonts and whatever else). That tells the browser

Many developers write about how to maintain a CSS codebase, yet not a lot of them write about how they measure the quality of that codebase. Sure, we have

Have you ever had a form that needed to accept a short, arbitrary bit of text? Like a name or whatever. That's exactly what is for. There are lots of

I'm so excited to be heading to Zürich, Switzerland for Front Conference (Love that name and URL!). I've never been to Switzerland before, so I'm excited

One of my favorite developments in software development has been the advent of serverless. As a developer who has a tendency to get bogged down in the details

In this post, we’ll be using an ecommerce store demo I built and deployed to Netlify to show how we can make dynamic routes for incoming data. It’s a fairly


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Notepad++7.3.1
Easy-to-use and free code editor