Easter Eggs in Websites
Contents
Easter eggs are hidden features, messages, or surprises built into software, websites, or digital media. They are often humorous or creative and intended to provide users with unexpected delight. On websites, Easter eggs can appear in the form of secret links, hidden animations, or special interactions accessible only through specific actions or inputs. These elements are usually undocumented and require a certain degree of curiosity from the user to discover them.
Types of Easter Eggs
The most common types of Easter eggs are listed here with some examples:
- Simple text
- Quotes
- Funny sayings
- Job offers
- ASCII art
- Animal characters
- Funny illustrations
- Company logos
- Encoded text or data
- Base64 encoded images
- URLs with URL encoding
- Text with ROT-13 encoding
- Morse code, geographical coordinates, etc.
- Graphics and photos
- Photos of the team
- Memes
- Animations, video or audio
- Videos of the team
- Funny animations
- Mini-games
- Text adventures
- Platform games
- Snakes, Tetris, Lemmings
Easter Egg Locations
Easter eggs, or at least clues to them, are usually hidden in visible and easily accessible locations. However, since there are so many hiding places, they are not always easy to find.
Possible locations include:
- HTML comments
- Text in alt and title attributes
- Hidden input fields in forms
- Visible but unobtrusive elements on the website
- Invisible text
- Text hidden with CSS
- Text color and background color are the same - only becomes visible when selected
- Text outside the visible area
- CSS comments or CSS classes
- JavaScript comments or string variables in JavaScript code
- Output via JavaScript to the developer tools console
- 404 error pages
- HTTP headers
- Known files
- /robots.txt as a comment or in a disallow rule
- /humans.txt
- /.well-known/security.txt
- manifest.json
- Embedded files, possibly from another domain
- Setting text in cookies or local storage
- EXIF data from photos or steganography in images
Easter Egg Triggers
Some Easter eggs require a specific trigger to appear. These triggers can include:
- Keyboard shortcuts
- Konami code (Up-Up-Down-Down-Left-Right-Left-Right-B-A)
- Specific inputs into text fields
- Words or names in a search field
- Inputs into an invisible text field using the developer tools
- Mouse actions
- Hovering over links or other elements
- Multiple clicks on a specific element
- Dragging and dropping elements
- Mouse gestures
- Technical triggers
- Browser, device, or operating system used
- Mobile / Desktop
- Offline mode
- Set language
- Display mode used (Dark mode)
- Screen resolution
- Zoom level
- Specific time or length of time spent on the website
- Accessing a URL with a specific parameter or anchor ("...?code=1337" or "...#easteregg")
- Browser, device, or operating system used
Examples
All examples are also included in the downloadable easter-eggs-test.html file.
To keep things simple, the stylesheets and JavaScript functions are embedded directly in the HTML file.
Comments
The simplest form of an Easter egg or hidden hint is text in a comment in an HTML, CSS, or JavaScript file. This is easy to find when viewing the source code. Here are some examples:
<!-- This is a secret message -->
/* (\(\ (-.-) (")(") */
<!-- _____ _ _ _ _ / ____| (_|_|_) | | | | __ __ _ _ _ _ _ __ __ _| |_ | | |_ |/ _` | | | | '_ \ / _` | __| | |__| | (_| | | | | | | || (_| | |_ \_____|\__,_|_| |_|_| |_(_)__,_|\__| _/ | |__/ Easter Egg Test Page https://www.gaijin.at/ -->
HTML Attributes
Here there is a message in the alt attribute and a reference to it in the title attribute, which displays a tooltip when the mouse pointer is positioned over the small square image.
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAAaElEQVR4AcXBQQ2EUBTAwG4DCQkOuCIBERjH118L79aZ3/u+i4Hrupg4joMJiUhEIhKRiEQkIhGJbPd9M7HWYmLfdyYkIhGJSEQiEpGIRCSyfd/HxPM8TJznyYREJCIRiUhEIhKRiET+ndMI9Tt+tD0AAAAASUVORK5CYII=" id="image" alt="This is a secret message" title="Hint: Inspect the element">
Data attributes can also be used to place custom text in an HTML tag:
<p data-secret="This is a secret message">This is a normal text.</p>
CSS Class
In the CSS class "secret" the content property contains an encoded URL:
.secret { content: 'https%3A%2F%2Fwww%2Egaijin%2Eat%2F'; }
The class does not need to be used in the HTML code. But a reference to the class could look like this:
<p>I am a <span class="secret">hint</span>.</p>
Invisible Text
A CSS class hide the paragraph containing the Easter egg by default. When the page containing the "secret" fragment is accessed, the Easter egg is displayed.
.normal-mode { display: none; } .easter-mode { display: block; }
<p id="frag" class="normal-mode">The page was loaded with the fragment "#secret".</p>
document.addEventListener('DOMContentLoaded', function() { if (location.hash === "#secret") { document.getElementById('frag').classList.add("easter-mode"); } });
Click with a key pressed
A message will be displayed here if the "Alt" key is held down while clicking the text.
<p id="clickme">Click me while pressing the Alt/Option key</p>
document.addEventListener('DOMContentLoaded', function(event) { document.getElementById('clickme').addEventListener('click', function(event) { if (event.altKey) { alert('This is a secret message'); } }); });
Console Output
The "console.log" function can be used to output text to the JavaScript console:
if (window.console) { console.log("This is a secret message"); }
Action when switching tabs or minimizing
The following code displays a message when the tab is changed or the browser window is minimized.
document.addEventListener("visibilitychange", () => { if (document.hidden) { console.log("This is a secret message - Goodbye"); } });
Cookie / Local Storage
Cookies or data in Local Storage can also contain hints. The next line stores a message to local storage.
localStorage.setItem("secret", "This is a secret message");
The message can be read (and deleted) using the developer tools.
Browser Offline Mode
If the browser has an offline mode, this can be checked with the following JavaScript code. Since not all web browsers have an offline mode, this method is also dependent on the browser used.
if (!navigator.onLine) { alert("Offline mode: This is a secret message"); }
Multiple Clicks
If the small square image (see "HTML Attributes") is clicked five times, this JavaScript displays a message. The line containing "setTimeout..." ensures that the counter is reset after five seconds. The time can, of course, be adjusted, or the entire line can be removed to prevent a time limit.
document.addEventListener('DOMContentLoaded', function(event) { let clicks = 0; const element = document.getElementById("image"); element.addEventListener("click", () => { clicks++; if (clicks >= 5) alert('This is a secret message'); setTimeout(() => clicks = 0, 5000); // reset after 5 seconds }); });
Konami Code
This JavaScript code displays a message when the Konami code is entered on the keyboard (keys: Up - Up - Down - Down - Left - Right - Left - Right - B - A).
const keysSequence = 'ArrowUp ArrowUp ArrowDown ArrowDown ArrowLeft ArrowRight ArrowLeft ArrowRight b a'; const keysSequenceLength = keysSequence.split(' ').length; const keysPressed = []; document.addEventListener('keyup', function(event) { // console.log(event.key); keysPressed.push(event.key); keysPressed.splice(0, keysPressed.length - keysSequenceLength); if (keysPressed.length != keysSequenceLength) return; if (keysPressed.join(' ').includes(keysSequence)) { alert('This is a secret message'); } });
To change the key sequence, the key names must be entered into the "keysSequence" variable. If the key codes are unknown, they can be output using the (commented) line
console.log(event.key);
in the JavaScript console of the developer tools.
HTTP Header
Any HTTP headers can be set using a .htaccess file or server-side programming language, such as:
X-Easter-Egg: This is a secret message
The HTTP headers can be viewed using the developer tools.
All examples are also included in the downloadable easter-eggs-test.html file.
Were the free content on my website helpful for you?
Support the further free publication with a donation via PayPal.