Every single HTML tag, attribute, and concept explained with real code examples. Copy, paste, and learn.
Choose one. Both are free. Both work perfectly.
Install Acode — Download "Acode Editor" from Google Play Store.
Create Folder — In Acode, tap menu → New Folder → name it prince-html-course
Create index.html — Inside the folder, create a new file named index.html
Paste Starter Code — Copy the code below into your file.
Preview — Tap the Play button or open in browser.
Download VS Code — Go to code.visualstudio.com and install.
Install Extensions — Search and install: Live Server, HTML CSS Support, Prettier.
Create Folder — Make a folder named Prince-HTML-Course on your desktop.
Create index.html — Right-click → New File → name it index.html
Run with Live Server — Right-click the file → "Open with Live Server"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First Website</title>
</head>
<body>
<h1>Hello World!</h1>
<p>I am learning HTML.</p>
</body>
</html>
Click any module to expand and learn. 40 modules from beginner to advanced.
Document structure, DOCTYPE, html, head, body tags
Every HTML document starts with a basic structure. Understanding this skeleton is the foundation of web development.
<!DOCTYPE html>Declares the document as HTML5<html>Root element of the page<head>Contains metadata (not visible on page)<body>Contains all visible content<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Create a new file called index.html and type this exact code. Open it in your browser.
Title, meta, link, style, and script tags
The <head> section holds crucial information about your webpage that browsers and search engines need.
<title>Page title shown in browser tab<meta charset>Character encoding (UTF-8 recommended)<meta viewport>Makes page responsive on mobile<meta description>SEO description for search engines<link rel="stylesheet">Links external CSS file<link rel="icon">Sets the browser tab favicon<style>Internal CSS styles<script>JavaScript code or external JS link<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Learn HTML with Prince Academy">
<title>My Awesome Website</title>
<link rel="stylesheet" href="style.css">
<link rel="icon" href="favicon.ico">
</head>
Add a viewport meta tag and a custom description to your page head.
Headings, paragraphs, line breaks, horizontal rules
Text is the backbone of the web. Learn how to structure it properly with headings and paragraphs.
<h1> to <h6>Headings from largest (h1) to smallest (h6)<p>Paragraph block of text<br>Line break (single, no closing tag)<hr>Horizontal rule / thematic break<h1>Main Title</h1> <h2>Subsection</h2> <h3>Sub-subsection</h3> <p>This is a paragraph of text.</p> <p>This is another paragraph.<br>With a line break inside.</p> <hr> <p>Content after a horizontal line.</p>
Create a page with all 6 heading levels and 3 paragraphs separated by horizontal rules.
Bold, italic, underline, strikethrough, sub, sup
Make your text stand out with formatting tags. Learn the difference between semantic and presentational tags.
<strong>Important text (bold, semantic)<b>Bold text (presentational)<em>Emphasized text (italic, semantic)<i>Italic text (presentational)<u>Underlined text<del>Deleted/strikethrough text<ins>Inserted/underlined text<sub>Subscript (H₂O)<sup>Superscript (x²)<small>Smaller text (fine print)<p><strong>Warning:</strong> This is important.</p> <p>Water formula: H<sub>2</sub>O</p> <p>Math: x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup></p> <p>Price: <del>$99</del> <ins>$49</ins></p> <p><small>Terms and conditions apply.</small></p>
Write a product description using strong, em, del, ins, sub, and sup tags.
Ordered lists, unordered lists, definition lists
Lists organize information. HTML has three types: ordered, unordered, and definition lists.
<ul>Unordered list (bullets)<ol>Ordered list (numbers/letters)<li>List item (inside ul or ol)<dl>Definition list<dt>Definition term<dd>Definition description<!-- Unordered List -->
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<!-- Ordered List with type -->
<ol type="A">
<li>Step One</li>
<li>Step Two</li>
<li>Step Three</li>
</ol>
<!-- Definition List -->
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets</dd>
</dl>
Create a nested list: a main list of 3 programming languages, each with 2 framework sub-items.
Hyperlinks, internal links, external links, mailto
Links connect the web. Learn to create hyperlinks, internal anchors, email links, and download links.
href="URL"Destination addresstarget="_blank"Open in new tabtarget="_self"Open in same tab (default)downloadTriggers file downloadrel="nofollow"Tells search engines not to follow<!-- External Link --> <a href="https://google.com" target="_blank">Visit Google</a> <!-- Internal Link --> <a href="about.html">About Page</a> <!-- Anchor Link --> <a href="#section2">Jump to Section 2</a> <h2 id="section2">Section 2</h2> <!-- Email Link --> <a href="mailto:someone@email.com">Send Email</a> <!-- Download Link --> <a href="file.pdf" download>Download PDF</a>
Create a navigation menu with 4 links: Home, About, Contact (mailto), and a Resume download.
img tag, src, alt, width, height, figure, figcaption
Images make websites visual. Learn the img tag, responsive images, and figure captions.
<img>Image element (self-closing)src=""Image source URL or pathalt=""Alternative text for accessibilitywidth=""Image width in pixelsheight=""Image height in pixelsloading="lazy"Lazy load for performance<figure>Self-contained content container<figcaption>Caption for a figure<!-- Basic Image -->
<img src="photo.jpg" alt="A beautiful sunset" width="400" height="300">
<!-- Lazy Loaded Image -->
<img src="big-image.jpg" alt="Large photo" loading="lazy">
<!-- Figure with Caption -->
<figure>
<img src="chart.png" alt="Sales chart">
<figcaption>Figure 1: Annual Sales Growth</figcaption>
</figure>
Add 3 images to your page with proper alt text. Wrap one in a figure with a figcaption.
Table, tr, th, td, thead, tbody, tfoot, colspan, rowspan
Tables display tabular data. Learn to create rows, columns, headers, and merge cells.
<table>Table container<thead>Table header group<tbody>Table body group<tfoot>Table footer group<tr>Table row<th>Table header cell<td>Table data cellcolspan=""Span across multiple columnsrowspan=""Span across multiple rows<table border="1">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
</tr>
</thead>
<tbody>
<tr>
<td>Alice</td>
<td>25</td>
<td>New York</td>
</tr>
<tr>
<td>Bob</td>
<td colspan="2">Data Missing</td>
</tr>
</tbody>
</table>
Create a 4x4 table with student grades. Use colspan and rowspan at least once.
Form tag, action, method, input types
Forms collect user input. Learn the form element and its essential attributes.
<form>Form containeraction=""URL where data is sentmethod="GET"Data in URL (for search)method="POST"Data in body (secure)enctype=""Encoding for file uploadsautocomplete="on"Browser auto-fillnovalidateSkip HTML5 validation<form action="/submit" method="POST">
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<button type="submit">Submit</button>
</form>
Create a contact form with Name, Email, and Message fields using proper labels.
Text, password, email, number, date, color
HTML5 introduced many new input types for better user experience and built-in validation.
type="text"Single-line texttype="password"Hidden characterstype="email"Email with validationtype="number"Numeric inputtype="tel"Telephone numbertype="url"URL with validationtype="date"Date pickertype="time"Time pickertype="color"Color pickertype="range"Slider controltype="file"File uploadtype="search"Search field<input type="text" placeholder="Your name"> <input type="email" placeholder="you@email.com"> <input type="password" placeholder="Password"> <input type="number" min="1" max="100"> <input type="date"> <input type="color" value="#ff0000"> <input type="range" min="0" max="10"> <input type="file" accept=".pdf,.doc">
Build a registration form using at least 6 different input types.
Checkbox, radio, select, textarea, button
Beyond text inputs, forms need checkboxes, radio buttons, dropdowns, and text areas.
<input type="checkbox">Multiple selections allowed<input type="radio">Single selection only<select>Dropdown list<option>Item in a select list<optgroup>Grouped options<textarea>Multi-line text input<button>Clickable button<datalist>Autocomplete suggestions<!-- Checkbox -->
<label><input type="checkbox" name="hobby" value="coding"> Coding</label>
<label><input type="checkbox" name="hobby" value="gaming"> Gaming</label>
<!-- Radio -->
<label><input type="radio" name="gender" value="male"> Male</label>
<label><input type="radio" name="gender" value="female"> Female</label>
<!-- Select -->
<select name="country">
<option value="">Choose...</option>
<option value="us">USA</option>
<option value="uk">UK</option>
</select>
<!-- Textarea -->
<textarea rows="4" cols="50" placeholder="Your message..."></textarea>
Create a pizza order form with size (radio), toppings (checkbox), and delivery notes (textarea).
Placeholder, required, pattern, min, max
Control how form inputs behave with powerful HTML5 attributes for validation and UX.
placeholder=""Hint text inside inputrequiredField must be filledreadonlyCannot be editeddisabledGrayed out, not submittedpattern="[A-Za-z]+"Regex validationmin="" max=""Minimum and maximum valuesstep=""Increment step for numbersmaxlength=""Maximum character countminlength=""Minimum character countautofocusAuto-focus on page loadautocomplete="off"Disable auto-fillmultipleAllow multiple selections<input type="text" placeholder="Username" required minlength="3" maxlength="20">
<input type="email" placeholder="Email" required autofocus>
<input type="number" min="18" max="99" step="1" placeholder="Age">
<input type="text" pattern="[A-Za-z]{3,}" title="Only letters, min 3 chars">
<input type="file" accept="image/*" multiple>
Create a validated signup form: username (3-15 chars, letters only), password (min 8), age (18-100).
Header, nav, main, section, article, aside, footer
Semantic HTML gives meaning to your structure. It helps SEO, accessibility, and code readability.
<header>Introductory content / nav<nav>Navigation links<main>Primary content (one per page)<section>Thematic grouping of content<article>Self-contained content (blog post)<aside>Sidebar / tangentially related content<footer>Footer for section or page<address>Contact information<body>
<header>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
</nav>
</header>
<main>
<article>
<h1>Blog Post Title</h1>
<p>Content here...</p>
</article>
<aside>
<h3>Related Posts</h3>
</aside>
</main>
<footer>
<p>© 2026 My Site</p>
</footer>
</body>
Rebuild your page using only semantic tags. No divs allowed for structure!
Audio, video, source, track, embed
Embed audio and video natively in HTML5 without plugins like Flash.
<audio>Audio player<video>Video player<source>Media source file<track>Subtitles/captions<embed>External content (plugin)controlsShow play/pause buttonsautoplayAuto-play on loadloopRepeat playbackmutedStart mutedpreload="auto"Preload media<!-- Audio -->
<audio controls>
<source src="music.mp3" type="audio/mpeg">
<source src="music.ogg" type="audio/ogg">
Your browser does not support audio.
</audio>
<!-- Video -->
<video width="640" height="360" controls poster="thumb.jpg">
<source src="movie.mp4" type="video/mp4">
<track src="subtitles.vtt" kind="subtitles" srclang="en" label="English">
</video>
Add a video player with controls and a poster image. Add an audio player below it.
iframe, src, width, height, sandbox
iFrames embed external web pages or content inside your page.
<iframe>Inline frame containersrc=""Source URL to embedwidth="" height=""Dimensionsframeborder="0"Remove borderallowfullscreenAllow full screen modeloading="lazy"Lazy load iframesandbox=""Security restrictionssrcdoc=""Inline HTML content<!-- Embed a YouTube Video -->
<iframe width="560" height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
frameborder="0"
allowfullscreen>
</iframe>
<!-- Embed Google Maps -->
<iframe
src="https://maps.google.com/maps?q=location&output=embed"
width="600" height="450"
style="border:0;">
</iframe>
<!-- Secure Sandbox -->
<iframe src="external.html" sandbox="allow-scripts"></iframe>
Embed a YouTube video and a Google Map on your page using iframes.
Block vs inline, div containers, span styling
Div and span are generic containers. Understanding block vs inline is crucial for layout.
<div>Block-level container (full width)<span>Inline container (within text)display: blockStarts on new line, takes full widthdisplay: inlineFlows with text, width by contentdisplay: inline-blockInline flow but block properties<!-- Block: div -->
<div style="background: #333; padding: 20px;">
<p>This div is a block container.</p>
</div>
<!-- Inline: span -->
<p>The word <span style="color: red;">important</span> is highlighted.</p>
<!-- Grouping -->
<div class="card">
<h3>Card Title</h3>
<p>Card content with <span class="badge">NEW</span> label.</p>
</div>
Create a card layout with a div container, and use span to highlight keywords inside paragraphs.
Special characters, symbols, non-breaking space
Special characters and symbols that can't be typed directly need HTML entities.
&Ampersand &<Less than <>Greater than >©Copyright ©®Registered ®™Trademark ™ Non-breaking space€Euro sign €£Pound sign £¥Yen sign ¥♥Heart ♥—Em dash —<p>5 < 10 and 10 > 5</p> <p>Copyright © 2026 Prince Academy</p> <p>Price: €99.99 or £85.00</p> <p>Made with ♥ by Prince</p> <p>This word won't break</p> <!-- Displaying code --> <p>Use <div> for containers.</p>
Create a footer with copyright, trademark, and a heart symbol. Show HTML code inside a paragraph.
HTML comments, meta tags, charset, viewport
Comments help document code. Meta tags tell browsers and search engines about your page.
<!-- comment -->HTML comment (not rendered)<meta charset="UTF-8">Character set<meta name="viewport">Responsive viewport<meta name="description">Page description for SEO<meta name="keywords">Keywords (less important now)<meta name="author">Page author<meta http-equiv="refresh">Auto-refresh page<meta property="og:title">Open Graph for social sharing<!-- This is a comment -->
<!-- TODO: Add navigation menu -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Learn HTML from scratch">
<meta name="author" content="Prince Academy">
<meta property="og:title" content="Prince HTML Academy">
<meta property="og:image" content="banner.jpg">
</head>
Add comments to your HTML explaining each section. Add Open Graph meta tags for social sharing.
Quotations, citations, abbreviations, definitions
Quote and cite sources properly. Use semantic tags for quotations and definitions.
<blockquote>Long quotation (block level)<q>Short inline quotation<cite>Title of creative work<abbr>Abbreviation with title<dfn>Definition term<address>Contact information<blockquote cite="https://example.com">
<p>The only way to do great work is to love what you do.</p>
<footer>— <cite>Steve Jobs</cite></footer>
</blockquote>
<p>He said, <q>HTML is the backbone of the web.</q></p>
<p><abbr title="HyperText Markup Language">HTML</abbr> is essential.</p>
<p><dfn>Semantic HTML</dfn> gives meaning to structure.</p>
<address>
Prince Academy<br>
Email: <a href="mailto:hello@prince.com">hello@prince.com</a>
</address>
Create a testimonials section with 2 blockquotes, an abbreviation, and your contact address.
Code blocks, preformatted text, kbd, samp, var
Display code snippets and preformatted text with proper semantic tags.
<code>Inline code snippet<pre>Preformatted text (preserves spaces)<kbd>Keyboard input<samp>Sample output<var>Variable in math/programming<!-- Inline code -->
<p>Use the <code>console.log()</code> function.</p>
<!-- Code block -->
<pre><code>
function greet(name) {
return "Hello, " + name + "!";
}
console.log(greet("World"));
</code></pre>
<!-- Keyboard shortcuts -->
<p>Press <kbd>Ctrl</kbd> + <kbd>S</kbd> to save.</p>
<!-- Variables -->
<p>The area of a circle is <var>pi</var><var>r</var><sup>2</sup>.</p>
Create a tutorial page showing HTML code inside pre+code blocks and keyboard shortcuts using kbd.
Collapsible content, dialog, progress, meter
Create interactive collapsible content, dialogs, and progress indicators.
<details>Collapsible content container<summary>Visible heading for details<dialog>Modal dialog box<progress>Progress bar<meter>Scalar measurement gauge<!-- Accordion / FAQ -->
<details>
<summary>What is HTML?</summary>
<p>HTML stands for HyperText Markup Language.</p>
</details>
<details open>
<summary>Why learn HTML?</summary>
<p>It's the foundation of every website.</p>
</details>
<!-- Progress Bar -->
<label>Uploading: <progress value="70" max="100">70%</progress></label>
<!-- Meter Gauge -->
<label>Disk Usage: <meter value="0.6">60%</meter></label>
<!-- Dialog (requires JS to show) -->
<dialog id="myDialog">
<p>This is a modal dialog!</p>
<button onclick="this.closest('dialog').close()">Close</button>
</dialog>
Create an FAQ section with 3 details/summary pairs and a progress bar showing 45%.
Time tag, data tag, machine-readable formats
Make dates, times, and data machine-readable for browsers and search engines.
<time>Machine-readable date/timedatetime=""ISO 8601 format<data>Machine-readable data valuevalue=""Machine-readable value<!-- Time Tag --> <p>Published on <time datetime="2026-06-12">June 12, 2026</time>.</p> <p>Meeting at <time datetime="14:30">2:30 PM</time>.</p> <p>Event: <time datetime="2026-12-25T00:00:00">Christmas 2026</time></p> <!-- Data Tag --> <p>Product ID: <data value="SKU-12345">#12345</data></p> <p>Price: <data value="49.99">$49.99</data></p> <!-- ISO 8601 Formats --> <!-- Date: YYYY-MM-DD --> <!-- Time: HH:MM:SS --> <!-- DateTime: YYYY-MM-DDTHH:MM:SS -->
Create a blog post meta section with published date, reading time, and product price using time and data tags.
Highlighting text, word breaks, ruby annotations
Highlight text, control word breaks, and add ruby annotations for East Asian typography.
<mark>Highlighted/marked text<wbr>Word break opportunity<ruby>Ruby annotation container<rt>Ruby text (pronunciation)<rp>Fallback for browsers without ruby<!-- Highlighted Text -->
<p>Search results for <mark>HTML5</mark> tags.</p>
<!-- Word Break -->
<p>Supercalifragilisticexpialidocious<wbr>is a long word.</p>
<!-- Ruby Annotation -->
<ruby>
漢 <rt>かん</rt>
字 <rt>じ</rt>
</ruby>
<!-- Ruby with Fallback -->
<ruby>
漢字
<rp>(</rp><rt>かんじ</rt><rp>)</rp>
</ruby>
Create a search results page highlighting keywords with mark. Add a very long URL with wbr breaks.
Canvas element, 2D context, drawing shapes
The canvas element lets you draw graphics, charts, and animations with JavaScript.
<canvas>Drawing surfacegetContext("2d")Get 2D rendering contextfillRect()Draw filled rectanglestrokeRect()Draw rectangle outlinefillText()Draw textarc()Draw circle/arcbeginPath()Start a new pathstroke()Draw the path<canvas id="myCanvas" width="400" height="200"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
// Fill rectangle
ctx.fillStyle = '#6366f1';
ctx.fillRect(50, 50, 100, 80);
// Draw circle
ctx.beginPath();
ctx.arc(250, 90, 40, 0, 2 * Math.PI);
ctx.fillStyle = '#ec4899';
ctx.fill();
// Draw text
ctx.fillStyle = '#fff';
ctx.font = '20px Poppins';
ctx.fillText('Hello Canvas!', 120, 160);
</script>
Draw a smiley face on canvas using arcs for eyes and mouth, and a fillRect for the face.
SVG element, shapes, paths, viewBox
SVG (Scalable Vector Graphics) creates crisp graphics that scale to any size.
<svg>SVG containerviewBox=""Coordinate system<rect>Rectangle<circle>Circle<ellipse>Ellipse<line>Straight line<polyline>Connected lines<polygon>Closed shape<path>Complex shapes<text>Text in SVG<svg width="200" height="200" viewBox="0 0 200 200">
<rect x="10" y="10" width="80" height="80" fill="#6366f1" rx="10" />
<circle cx="150" cy="50" r="40" fill="#ec4899" />
<line x1="10" y1="120" x2="190" y2="120" stroke="#f59e0b" stroke-width="4" />
<polygon points="100,140 120,190 80,190" fill="#22c55e" />
<text x="50" y="170" fill="white" font-size="16">SVG!</text>
</svg>
Create an SVG icon set: a star, a heart, and a checkmark using polygon and path elements.
Custom data attributes, dataset API
Custom data attributes let you store extra info in HTML elements for JavaScript to use.
data-*=""Custom data attributedatasetJavaScript property to accesselement.dataset.nameAccess data-name in JS<!-- HTML -->
<div class="product"
data-id="123"
data-price="49.99"
data-category="electronics">
Wireless Headphones
</div>
<button id="showData">Show Data</button>
<script>
const product = document.querySelector('.product');
const btn = document.getElementById('showData');
btn.addEventListener('click', () => {
console.log(product.dataset.id); // "123"
console.log(product.dataset.price); // "49.99"
console.log(product.dataset.category); // "electronics"
});
</script>
Create 3 product cards with data attributes for price, rating, and stock. Use JS to display them on click.
Roles, labels, landmarks, screen readers
ARIA (Accessible Rich Internet Applications) makes your website usable for everyone, including screen reader users.
role="banner"Site headerrole="navigation"Nav linksrole="main"Main contentrole="complementary"Sidebar contentrole="contentinfo"Footer infoaria-label=""Accessible labelaria-hidden="true"Hide from screen readersaria-expanded=""State of expandable content<!-- Accessible Navigation -->
<nav role="navigation" aria-label="Main Menu">
<a href="#" aria-current="page">Home</a>
<a href="#">About</a>
</nav>
<!-- Accessible Button -->
<button aria-label="Close menu" onclick="toggleMenu()">
<i class="fas fa-times" aria-hidden="true"></i>
</button>
<!-- Accessible Alert -->
<div role="alert" aria-live="polite">
Your changes have been saved.
</div>
Add ARIA labels to your navigation, form, and buttons. Test with a screen reader if possible.
Meta descriptions, Open Graph, structured data
Optimize your HTML for search engines to rank higher and get more visitors.
<title>Page title (50-60 chars)meta descriptionSnippet in search resultsmeta robotsIndex/noindex instructionscanonicalPreferred URL versionog:titleSocial media titleog:imageSocial media imagetwitter:cardTwitter card type<h1>One per page, main keyword<head>
<title>Learn HTML - Free Complete Course | Prince Academy</title>
<meta name="description" content="Master HTML from scratch...">
<meta name="robots" content="index, follow">
<link rel="canonical" href="https://princeacademy.com/html">
<!-- Open Graph -->
<meta property="og:title" content="Learn HTML Course">
<meta property="og:description" content="Free HTML course...">
<meta property="og:image" content="banner.jpg">
<meta property="og:type" content="website">
<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="@princeacademy">
</head>
Add complete SEO meta tags to your page including Open Graph and Twitter cards.
Template tag, slot, shadow DOM basics
HTML templates let you define reusable content that isn't rendered until cloned by JavaScript.
<template>Hidden reusable HTML fragment<slot>Placeholder in shadow DOMcontent.cloneNode(true)Clone template contentshadowRootEncapsulated DOM tree<!-- Define Template -->
<template id="card-template">
<div class="card">
<h3></h3>
<p></p>
</div>
</template>
<div id="card-container"></div>
<script>
const template = document.getElementById('card-template');
const container = document.getElementById('card-container');
const clone = template.content.cloneNode(true);
clone.querySelector('h3').textContent = 'Card Title';
clone.querySelector('p').textContent = 'Card description.';
container.appendChild(clone);
</script>
Create a template for a product card with image, title, and price. Clone it 3 times with different data.
Custom elements, shadow DOM, HTML imports
Web Components let you create reusable custom HTML elements with encapsulated styles and behavior.
customElements.define()Register custom elementconnectedCallback()When element added to DOMattachShadow()Create shadow DOM<slot>Content projection<hello-world name="Prince"></hello-world>
<script>
class HelloWorld extends HTMLElement {
connectedCallback() {
const name = this.getAttribute('name') || 'World';
this.innerHTML = `<h2>Hello, ${name}!</h2>`;
}
}
customElements.define('hello-world', HelloWorld);
</script>
Create a custom user-card element that accepts name, role, and avatar attributes.
Mathematical markup, fractions, roots, matrices
MathML lets you display mathematical formulas directly in HTML without images.
<math>Math container<mrow>Horizontal group<mi>Identifier (variable)<mo>Operator<mn>Number<mfrac>Fraction<msup>Superscript<msqrt>Square root<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo>-</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<mrow>
<msup><mi>b</mi><mn>2</mn></msup>
<mo>-</mo>
<mn>4</mn><mi>a</mi><mi>c</mi>
</mrow>
</msqrt>
</mrow>
<mrow><mn>2</mn><mi>a</mi></mrow>
</mfrac>
</mrow>
</math>
Write the Pythagorean theorem (a² + b² = c²) using MathML.
Schema.org, itemscope, itemprop, vocabularies
Microdata adds structured data that search engines use to create rich snippets.
itemscopeCreates a new itemitemtype=""Schema.org vocabulary URLitemprop=""Property nameitemref=""Reference external properties<!-- Person Schema -->
<div itemscope itemtype="https://schema.org/Person">
<h2 itemprop="name">Prince</h2>
<img itemprop="image" src="photo.jpg" alt="Prince">
<p itemprop="jobTitle">Web Developer</p>
<div itemprop="address" itemscope itemtype="https://schema.org/PostalAddress">
<span itemprop="addressLocality">New York</span>
</div>
</div>
<!-- Product Schema -->
<div itemscope itemtype="https://schema.org/Product">
<h2 itemprop="name">HTML Course</h2>
<span itemprop="price">$49.99</span>
<span itemprop="priceCurrency">USD</span>
</div>
Add Person schema to your about page and Product schema to a course listing.
W3C validator, common errors, best practices
Validate your HTML to catch errors and ensure cross-browser compatibility.
W3C Validatorvalidator.w3.orgDOCTYPEAlways declare HTML5lang attrSet language on html tagalt textEvery image needs altclosing tagsClose all non-void tagsquotesUse double quotes for attributes<!-- CORRECT -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Valid Page</title>
</head>
<body>
<img src="photo.jpg" alt="Description" width="400">
<p>This is <strong>valid</strong> HTML.</p>
</body>
</html>
<!-- COMMON ERRORS TO AVOID -->
<!-- Missing alt on images -->
<!-- Unclosed tags -->
<!-- Duplicate IDs -->
<!-- Missing DOCTYPE -->
Run your HTML through the W3C validator. Fix any errors or warnings found.
Lazy loading, preload, prefetch, resource hints
Optimize your HTML for faster loading and better user experience.
loading="lazy"Defer image loadingpreloadPriority load critical resourcesprefetchLoad next page resourcesasyncLoad script without blockingdeferDefer script executiondns-prefetchPre-resolve DNS<!-- Preload critical font --> <link rel="preload" href="fonts/main.woff2" as="font" type="font/woff2" crossorigin> <!-- Prefetch next page --> <link rel="prefetch" href="about.html"> <!-- DNS Prefetch --> <link rel="dns-prefetch" href="//fonts.googleapis.com"> <!-- Lazy Images --> <img src="photo.jpg" alt="Photo" loading="lazy"> <!-- Async Script --> <script src="analytics.js" async></script> <!-- Defer Script --> <script src="app.js" defer></script>
Add preload for your main font, lazy loading for images below the fold, and defer for non-critical JS.
Picture element, srcset, sizes, art direction
Serve the right image size for every device with responsive image techniques.
<picture>Art direction container<source>Different image sourcessrcset=""Multiple resolution imagessizes=""Image display sizesmedia=""Media query condition<!-- Art Direction with Picture -->
<picture>
<source media="(min-width: 800px)" srcset="hero-large.jpg">
<source media="(min-width: 400px)" srcset="hero-medium.jpg">
<img src="hero-small.jpg" alt="Hero image">
</picture>
<!-- Resolution Switching -->
<img srcset="photo-400.jpg 400w,
photo-800.jpg 800w,
photo-1200.jpg 1200w"
sizes="(max-width: 600px) 100vw,
(max-width: 1000px) 50vw,
33vw"
src="photo-800.jpg"
alt="Responsive photo">
Create a hero section that shows a wide banner on desktop and a cropped portrait on mobile using picture.
Email-safe HTML, tables for layout, inline styles
HTML email uses table-based layouts for maximum compatibility across email clients.
<table>Primary layout toolinline CSSNo external stylesheetswidth=""Table cell widthsalt=""All images need altno JSJavaScript does not work600pxMax recommended width<table width="600" cellpadding="0" cellspacing="0" border="0" align="center">
<tr>
<td bgcolor="#6366f1" style="padding: 20px; text-align: center;">
<h1 style="color: white; margin: 0;">Welcome!</h1>
</td>
</tr>
<tr>
<td style="padding: 30px; font-family: Arial, sans-serif;">
<p style="color: #333;">Thanks for joining Prince Academy.</p>
<a href="#" style="background: #6366f1; color: white; padding: 12px 24px; text-decoration: none; display: inline-block; border-radius: 4px;">Get Started</a>
</td>
</tr>
</table>
Create a newsletter email template with a header, body text, and a CTA button using table layout.
Graceful degradation, feature detection
Build websites that work for everyone, regardless of browser or device capabilities.
semantic HTMLWorks without CSS/JSfeature detectionCheck before using new featuresnoscriptContent for no-JS browserspictureFallback image formatstype="module"Modern JS with fallback<!-- Works without JS -->
<form action="/search" method="GET">
<input type="search" name="q" placeholder="Search...">
<button type="submit">Search</button>
</form>
<!-- Fallback for no JS -->
<noscript>
<p>Please enable JavaScript for the best experience.</p>
</noscript>
<!-- Picture with fallback -->
<picture>
<source srcset="image.avif" type="image/avif">
<source srcset="image.webp" type="image/webp">
<img src="image.jpg" alt="Photo">
</picture>
<!-- Modern JS with fallback -->
<script type="module" src="app.mjs"></script>
<script nomodule src="app.js"></script>
Build a search form that works without JavaScript. Add a noscript message and image format fallbacks.
Geolocation, localStorage, drag & drop, web workers
HTML5 provides powerful APIs that work with JavaScript for advanced functionality.
Geolocation APIGet user locationlocalStorageStore data in browsersessionStorageStore data per sessionDrag & Dropdraggable attributeWeb WorkersBackground JavaScriptNotificationsBrowser notifications<!-- Geolocation -->
<button onclick="getLocation()">Get Location</button>
<p id="loc"></p>
<script>
function getLocation() {
navigator.geolocation.getCurrentPosition(pos => {
document.getElementById('loc').textContent =
`Lat: ${pos.coords.latitude}, Lon: ${pos.coords.longitude}`;
});
}
// localStorage
localStorage.setItem('username', 'Prince');
const user = localStorage.getItem('username');
// Drag & Drop
// Add draggable="true" to any element
</script>
Create a page that stores a user's name in localStorage and greets them on return visits.
CSP, XSS prevention, HTTPS, sandboxing
Protect your users and your site with security best practices in HTML.
HTTPSAlways use SSL/TLSsandboxRestrict iframe capabilitiesrel="noopener"Prevent tabnabbingautocomplete="off"Don't save sensitive dataCSRF tokensPrevent cross-site request forgeryinput type="password"Mask sensitive input<!-- Secure External Links -->
<a href="https://external.com" target="_blank" rel="noopener noreferrer">
External Link
</a>
<!-- Secure iFrame -->
<iframe src="widget.html" sandbox="allow-scripts"></iframe>
<!-- Secure Form -->
<form action="/login" method="POST" autocomplete="off">
<input type="hidden" name="csrf_token" value="abc123">
<input type="text" name="username" autocomplete="username">
<input type="password" name="password" autocomplete="current-password">
</form>
<!-- Content Security Policy (in meta) -->
<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self'">
Add noopener to all external links. Create a secure login form with CSRF token and autocomplete off.
Minification, bundling, hosting, GitHub Pages
Prepare your HTML for production with minification, bundling, and deployment.
minificationRemove whitespace and commentsgzipCompress files on serverGitHub PagesFree static hostingNetlifyDrag & drop deploymentVercelFrontend deployment platform.htaccessServer configuration<!-- Before minification -->
<!--
This is my awesome website
Created by Prince Academy
-->
<div class="container">
<h1> Hello World </h1>
</div>
<!-- After minification -->
<div class="container"><h1>Hello World</h1></div>
<!-- .htaccess for caching -->
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 1 hour"
ExpiresByType image/jpeg "access plus 1 year"
</IfModule>
Deploy your completed HTML project to GitHub Pages or Netlify. Share the live URL!
Quick reference for the most common HTML tags and attributes.
<!DOCTYPE html>HTML5 declaration<html>Root element<head>Metadata container<body>Visible content<title>Page title<meta charset>Character encoding<h1> - <h6>Headings<p>Paragraph<br>Line break<hr>Horizontal rule<strong>Bold (semantic)<em>Italic (semantic)<a href>Hyperlink<img src>Image<audio>Audio player<video>Video player<iframe>Embed frametarget="_blank"New tab<ul>Unordered list<ol>Ordered list<li>List item<dl>Definition list<dt>Definition term<dd>Definition<table>Table container<tr>Table row<th>Header cell<td>Data cellcolspanSpan columnsrowspanSpan rows<form>Form container<input>Input field<label>Input label<select>Dropdown<textarea>Multi-line text<button>Clickable button<header>Page header<nav>Navigation<main>Main content<section>Thematic section<article>Self-contained content<footer>Page footertype="text"Text inputtype="email"Email inputtype="password"Passwordtype="number"Number inputtype="date"Date pickertype="checkbox"Checkbox