HTML Cheat Sheets

HTML comprehensive cheat sheet

Basic HTML Structure

HTML Document Structure

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

</body>
</html>

HTML Structure Resources

HTML5 Introduction https://developer.mozilla.org/en-US/doc…
W3Schools: HTML5 https://www.w3schools.com/html/html5_in…

Elements and Attributes

Common HTML Elements

<a>
Defines a hyperlink
<p>
Defines a paragraph
<div>
Defines a division or section
<span>
Defines a section in a document
<img>
Embeds an image

Elements and Attributes Resources

HTML Elements Reference https://developer.mozilla.org/en-US/doc…
W3Schools: HTML Elements https://www.w3schools.com/html/html_ele…

Forms and Input

Form Element

<form action="/submit" method="post">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name">
    <input type="submit" value="Submit">
</form>

Forms and Input Resources

HTML Forms Guide https://developer.mozilla.org/en-US/doc…
W3Schools: HTML Forms https://www.w3schools.com/html/html_for…

Semantic HTML

Semantic Elements

<header>
Defines a header for a document or section
<nav>
Defines navigation links
<section>
Defines a section in a document
<article>
Defines an independent piece of content
<footer>
Defines a footer for a document or section

Semantic HTML Resources

Semantic HTML Guide https://developer.mozilla.org/en-US/doc…
W3Schools: Semantic Elements https://www.w3schools.com/html/html5_se…

Multimedia

Embedding Video

<video width="320" height="240" controls>
    <source src="movie.mp4" type="video/mp4">
    Your browser does not support the video tag.
</video>

Multimedia Resources

HTML Multimedia https://developer.mozilla.org/en-US/doc…
W3Schools: HTML Multimedia https://www.w3schools.com/html/html_med…

Best Practices

HTML Best Practices

Use Semantic Elements
Improve accessibility and SEO
Validate HTML
Ensure cross-browser compatibility

Best Practices Resources

HTML Best Practices https://developer.mozilla.org/en-US/doc…
W3Schools: HTML Best Practices https://www.w3schools.com/html/html5_in…

Advanced HTML5 Features

Canvas Element

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
Your browser does not support the canvas element.
</canvas>

Advanced HTML5 Resources

HTML5 Canvas API https://developer.mozilla.org/en-US/doc…
HTML5 Features https://www.w3schools.com/html/html5_ne…

Accessibility

Accessibility Best Practices

Use ARIA Roles
Enhance accessibility for screen readers
Alt Text for Images
Provide text alternatives for images

Accessibility Resources

Web Accessibility Initiative https://www.w3.org/WAI/
ARIA Roles https://developer.mozilla.org/en-US/doc…

SEO Best Practices

SEO Tips

Use Meta Tags
Improve search engine visibility
Semantic HTML
Enhance content structure for SEO

SEO Resources

SEO Basics https://developers.google.com/search/do…
SEO Best Practices https://moz.com/beginners-guide-to-seo

Responsive Design

Media Queries

@media only screen and (max-width: 600px) {
    body {
        background-color: lightblue;
    }
}

Responsive Design Resources

Responsive Web Design Basics https://developers.google.com/web/funda…
Media Queries https://developer.mozilla.org/en-US/doc…

HTML5 APIs

Geolocation API

navigator.geolocation.getCurrentPosition(function(position) {
    console.log("Latitude: " + position.coords.latitude + 
    "
Longitude: " + position.coords.longitude);
});

HTML5 APIs Resources

Geolocation API https://developer.mozilla.org/en-US/doc…
HTML5 APIs https://www.w3schools.com/html/html5_in…

Progressive Web Apps (PWAs)

Service Workers

self.addEventListener("install", function(event) {
    event.waitUntil(
        caches.open("v1").then(function(cache) {
            return cache.addAll([
                "/",
                "/styles/main.css",
                "/script/main.js"
            ]);
        })
    );
});

PWA Resources

Service Workers https://developer.mozilla.org/en-US/doc…
Progressive Web Apps https://developers.google.com/web/progr…

HTML5 Security

Security Best Practices

Content Security Policy
Prevent XSS attacks
Secure Cookies
Use HttpOnly and Secure flags

Security Resources

Content Security Policy https://developer.mozilla.org/en-US/doc…
OWASP HTML5 Security https://owasp.org/www-project-secure-he…

Advanced Multimedia

Audio API

var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var oscillator = audioCtx.createOscillator();
oscillator.type = "square";
oscillator.frequency.setValueAtTime(440, audioCtx.currentTime);
oscillator.connect(audioCtx.destination);
oscillator.start();

Multimedia Resources

Web Audio API https://developer.mozilla.org/en-US/doc…
Advanced Multimedia https://www.w3schools.com/html/html5_au…

HTML5 Game Development

Game Loop

function gameLoop() {
    requestAnimationFrame(gameLoop);
    // Update game state
    // Render game
}
gameLoop();

Game Development Resources

HTML5 Game Development https://developer.mozilla.org/en-US/doc…
Game Loop https://developer.mozilla.org/en-US/doc…

HTML5 Graphics

SVG Basics

<svg width="100" height="100">
    <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
</svg>

Graphics Resources

SVG Guide https://developer.mozilla.org/en-US/doc…
Canvas vs SVG https://www.w3schools.com/html/html5_sv…

Web Components

Custom Elements

class MyElement extends HTMLElement {
    constructor() {
        super();
        this.attachShadow({ mode: "open" });
    }
}
customElements.define("my-element", MyElement);

Web Components Resources

Web Components Guide https://developer.mozilla.org/en-US/doc…
Custom Elements https://developer.mozilla.org/en-US/doc…

Internationalization

i18n Best Practices

Use lang Attribute
Specify language of content
Character Encoding
Use UTF-8 for universal compatibility

Internationalization Resources

i18n Guide https://www.w3schools.com/tags/ref_coun…
HTML i18n https://www.w3schools.com/tags/ref_lang…