HyperText Markup Language

HTML — Complete Tutorial

Learn HTML from absolute zero. Every topic explained simply with real examples you can edit and run live, right here in your browser.

🟩 Beginner Friendly ▶ Live Code Editor 📚 50 Topics
Your Progress3% complete
∙ Chapter 01

What is HTML?

HTML stands for HyperText Markup Language. It is the skeleton of every webpage — it tells the browser what content to show and how to structure it.

💡Think of it this way

Imagine building a house. HTML is the structure — walls, rooms, doors. CSS is the paint and decoration. JavaScript makes things interactive (lights, doors opening).

HTML uses tags like <h1> to mark up content. Browsers read these tags and display the page accordingly.

ℹ️HTML is NOT a programming language — it is a markup language. It describes structure, not logic.
<h1> – <h6>
Headings — titles and section headers
<p>
Paragraphs — blocks of text content
<a>
Anchor tags — create clickable links
<img>
Images — embed pictures on a page
hello.php
📝 Edit Code
👁 Live Preview
💡 Edit the code on the left and click Run to see the result instantly!
Chapter 02
∙ Chapter 02

HTML Structure

Every HTML page has the same basic skeleton. Understanding this is the foundation of everything you'll build.

🏗️The Basic Skeleton — line by line
  • 1<!DOCTYPE html> — Tells the browser "This is HTML5." Always the very first line.
  • 2<html> — The root element. Everything lives inside this tag.
  • 3<head> — Invisible info about the page (title, styles, metadata).
  • 4<title> — The text shown on the browser tab.
  • 5<body> — Everything the user sees: text, images, links, buttons.
Tip: HTML tags come in pairs — an opening <p> and a closing </p>. The closing tag has a forward slash.
structure.php
📝 Edit Code
👁 Live Preview
💡 Try changing the text inside <h1> and clicking Run again!
Chapter 03
∙ Chapter 03

HTML Headings

HTML has 6 heading levels — <h1> is the biggest and most important, <h6> is the smallest.

📋When to use each level

Think of a newspaper: the main headline is <h1>. Section titles are <h2>. Sub-topics are <h3>, and so on downward.

Use only one <h1> per page. Use as many h2–h6 as you need for structure.

⚠️Don't choose headings based on visual size. Use them for meaning and structure. Change size with CSS later.
headings.php
📝 Edit Code
👁 Live Preview
💡 Try changing h1 to h4 — the size decreases. All headings are bold by default.
Chapter 04
∙ Chapter 04

Paragraphs & Line Breaks

The <p> tag defines a paragraph. Browsers automatically add space before and after each one.

<p>
Paragraph block. Adds top & bottom spacing automatically.
<br>
Line break — new line without starting a new paragraph. Self-closing.
<hr>
Horizontal rule — draws a divider line across the page. Self-closing.
<pre>
Preformatted — preserves spaces and line breaks exactly as typed.
ℹ️Extra spaces or pressing Enter in HTML code does nothing visible — only tags create visual spacing.
paragraphs.php
📝 Edit Code
👁 Live Preview
💡 <br> and <hr> have no closing tags — they are self-closing elements.
Chapter 05
Chapter 06
∙ Chapter 06

HTML Images

The <img> tag displays images. It is self-closing (no closing tag). Always include the alt attribute for accessibility.

🖼️Important <img> attributes

src — the image path or URL. This is required.

alt — a text description. Used by screen readers for blind users, and shown when the image fails to load. Always include it!

width / height — controls size in pixels. Setting both prevents layout shifts while loading.

Extra attributeWhat it doesExample
loadingLazy loads offscreen imagesloading="lazy"
decodingHints how the browser decodesdecoding="async"
srcsetMultiple image sizes (responsive)srcset="320w,560w..."
Beginner rule: If the image is important content, write good alt. If it is decorative, use alt="".
images.php
📝 Edit Code
👁 Live Preview
💡 Wrapping <img> inside <a> makes the whole image a clickable link.
Chapter 07
∙ Chapter 07

Text Formatting

HTML has built-in tags to make text bold, italic, highlighted, strikethrough and more — each tag carries a specific meaning.

TagEffectBest used for
<strong>Bold + importantText with strong importance
<b>Bold onlyVisually bold, no extra meaning
<em>Italic + emphasisStressed or emphasized text
<i>Italic onlyForeign words, technical terms
<mark>Yellow highlightHighlighted content
<s>StrikethroughNo longer relevant content
<sub>Subscript H₂OChemical formulas, footnotes
<sup>Superscript x²Math exponents, ordinals
<code>Monospace code styleInline code snippets in text
formatting.php
📝 Edit Code
👁 Live Preview
💡 Tags can be nested — wrap <em> inside <strong> to get bold italic at once.
Chapter 08
∙ Chapter 08

HTML Comments

Comments are notes in your code that browsers completely ignore. They help you and your team understand the code.

💬Comment Syntax

Start with <!-- and end with -->. Everything between is invisible to users in the browser.

Uses: explain complex code, temporarily disable code without deleting it, leave TODO reminders for yourself.

comments.php
📝 Edit Code
👁 Live Preview
💡 Right-click the preview → Inspect — comments ARE visible in browser DevTools!
Chapter 09
∙ Chapter 09

HTML Colors

Colors in HTML are applied with the style attribute using CSS color properties. Multiple formats are supported.

FormatExampleNotes
Namered, blue, tomato140+ built-in color names
HEX#ff0000, #3498dbMost popular format in CSS
RGBrgb(255, 0, 0)Red, Green, Blue values 0–255
RGBArgba(255,0,0,0.5)Same + transparency (0=clear, 1=solid)
HSLhsl(0,100%,50%)Hue, Saturation, Lightness
colors.php
📝 Edit Code
👁 Live Preview
💡 Try replacing "tomato" with "coral" or change the hex code "#3498db" to "#e74c3c"!
Chapter 10
∙ Chapter 10

HTML Lists

HTML has three types of lists to group related items in a clear, organized way.

<ul>
Unordered list — bullet points. Order doesn't matter (shopping list, features).
<ol>
Ordered list — numbered. Order matters (steps, rankings, instructions).
<li>
List item — goes inside <ul> or <ol>. Every item needs its own <li>.
<dl> <dt> <dd>
Definition list — terms + definitions. Great for glossaries.
lists.php
📝 Edit Code
👁 Live Preview
💡 Lists can be nested — a <ul> inside an <li> creates an indented sub-list!
Chapter 11
∙ Chapter 11

HTML Tables

Tables display data in rows and columns — like a spreadsheet. Use them only for tabular data, never for page layout.

TagWhat it means
<table>The table container
<thead>Groups the header rows
<tbody>Groups the data rows
<tr>One horizontal row
<th>Header cell — bold & centered by default
<td>Data cell — regular content
colspan="2"Merges cells horizontally
rowspan="2"Merges cells vertically
ℹ️For better tables: add a <caption>, use <th scope="col">/<th scope="row">, and keep tables only for data (not layout).
tables.php
📝 Edit Code
👁 Live Preview
💡 Try adding a 4th row, or add colspan="2" to a <th> to merge two columns!
Chapter 12
∙ Chapter 12

Forms & Inputs

Forms collect information from users — login boxes, search bars, contact forms. The <form> tag wraps all input elements.

Input TypeWhat it creates
type="text"Single line text box
type="email"Email box (auto-validates format)
type="password"Password box (hides text)
type="number"Number input with up/down arrows
type="checkbox"Tick box — yes/no choice
type="radio"One choice from a group
type="range"Slider control
type="submit"Submit button
<textarea>Multi-line text area
<select>Dropdown menu
✍️How forms work (beginner)

action is where the data goes (a URL on your server).

method="get" puts data in the URL (good for search forms).

method="post" sends data in the request body (good for login/register).

name on inputs becomes the field key (example: name="email").

Accessibility: connect labels to inputs using for and matching id. This helps screen readers and makes clicking the label focus the input.
forms.php
📝 Edit Code
👁 Live Preview
💡 Try the password field — the text is automatically hidden!
Chapter 13
∙ Chapter 13

Div & Span

These containers have no visual appearance — they exist purely for grouping content to apply CSS or JavaScript.

📦The key difference

<div> is block-level — takes the full width and starts on a new line. Use it for layout sections and boxes.

<span> is inline — only takes the space of its content, lives inside text. Use it to style a specific word or phrase in a sentence.

divspan.php
📝 Edit Code
👁 Live Preview
💡 <div> = layout blocks. <span> = inline styling. Both invisible without CSS!
Chapter 14
∙ Chapter 14

HTML Attributes

Attributes provide extra information to HTML tags. They go inside the opening tag in name="value" format.

🔧Global attributes — work on ANY element

id="name" Unique identifier for one element. Used by CSS (#name) and JavaScript.

class="name" Groups elements. Multiple elements can share a class. Used by CSS (.name).

style="..." Adds inline CSS directly on the element.

title="text" Tooltip shown when user hovers over the element.

hidden Hides the element completely (like display:none in CSS).

attributes.php
📝 Edit Code
👁 Live Preview
💡 The hidden paragraph is in the code but invisible. Remove "hidden" to show it!
Chapter 15
∙ Chapter 15

Semantic HTML5

Semantic elements describe their meaning clearly. Always prefer them over generic <div> tags where possible.

🏛️Why semantics matter

Semantic tags help search engines understand your page, make code more readable, and help screen readers for visually impaired users.

Instead of <div id="header"> use <header>. Instead of <div id="nav"> use <nav>. Same look, much better meaning.

TagMeaning & Use
<header>Page or section header — logo, title, nav
<nav>A block of navigation links
<main>The main unique content (only one per page)
<section>Thematic grouping of related content
<article>Self-contained content (blog post, news story)
<aside>Side content — sidebar, related links
<footer>Footer — copyright, contact, links
<figure> / <figcaption>Image with a descriptive caption below
semantic.php
📝 Edit Code
👁 Live Preview
💡 A complete semantic layout — header, nav, main, article, aside and footer in one!
Chapter 16
∙ Chapter 16

Audio & Video

HTML5 added native <audio> and <video> elements. No plugins needed — media works right in the browser.

AttributeWhat it does
controlsShows play/pause/volume controls
autoplayStarts playing automatically on load
loopReplays when the video/audio finishes
mutedStarts with sound turned off
poster(Video only) Image shown before playing
width / heightSets the size of the player
media.php
📝 Edit Code
👁 Live Preview
💡 The <source> tag inside <video> lets you provide multiple formats as fallbacks.
Chapter 17
∙ Chapter 17

Meta Tags & <head>

The <head> section contains metadata — invisible information that describes your page to browsers, search engines and social media.

🧠Essential head elements every page needs

<meta charset="UTF-8"> — UTF-8 supports all characters worldwide. Always include first.

<meta name="viewport" content="width=device-width, initial-scale=1.0"> — Makes your page look correct on mobile phones. Always include this!

<meta name="description" content="..."> — The description shown in Google search results.

<link rel="stylesheet" href="style.css"> — Links your external CSS file.

<script src="app.js"></script> — Links your JS file. Best placed just before </body>.

meta.php
📝 Edit Code
👁 Live Preview
💡 Meta tags are invisible on the page but critical for SEO and mobile compatibility.
Chapter 18
∙ Chapter 18

Block vs Inline Elements

Some elements start on a new line and stretch (block). Others live inside a line of text (inline). Knowing this makes layout and styling much easier.

📦Quick rule

Block: takes full width, starts new line (example: <div>, <p>, <h2>, <ul>).

Inline: takes only needed width, stays in the same line (example: <span>, <a>, <strong>, <em>).

block-inline.php
📝 Edit Code
👁 Live Preview
💡 CSS can change display (e.g. display:inline-block), but HTML defaults matter for understanding.
Chapter 19
∙ Chapter 19

Classes & IDs

class is for groups (many elements). id is unique (one element). They are used for CSS styling, JavaScript selection, and page links like href="#section".

ℹ️Tip: Prefer classes for styling. Use IDs for unique anchors or when you truly need a one-off target.
class-id.php
📝 Edit Code
👁 Live Preview
💡 One element can have many classes, but an ID should be unique on the page.
Chapter 20
∙ Chapter 20

HTML Entities (& Symbols)

Some characters have special meaning in HTML, like < and &. Entities are safe ways to display them as text.

EntityShowsWhy
&lt;<Show a < character
&gt;>Show a > character
&amp;&Show an & character
&quot;"Show a double quote
&nbsp;(space)Non-breaking space
entities.php
📝 Edit Code
👁 Live Preview
💡 If you type < directly, the browser may think you are starting a tag.
Chapter 21
∙ Chapter 21

Iframes & Embeds

<iframe> lets you embed another webpage inside your page (maps, videos, dashboards). Use it carefully for performance and security.

⚠️For untrusted content, use sandbox to restrict what the embedded page can do.
iframes.php
📝 Edit Code
👁 Live Preview
💡 Use sandbox when embedding untrusted content to reduce risk.
Chapter 22
∙ Chapter 22

Responsive Images (srcset)

Modern HTML can load the best image size for the user's screen. This makes pages faster, especially on mobile.

🖼️What changes

src is the default image.

srcset provides multiple sizes. The browser chooses the best one.

sizes tells the browser how wide the image will be on the page.

responsive-images.php
📝 Edit Code
👁 Live Preview
💡 width:100% + height:auto keeps images proportional.
Chapter 23
∙ Chapter 23

Accessibility Basics

Accessible HTML works for everyone, including people using screen readers or keyboards. Good accessibility also improves SEO and usability.

PracticeWhy it matters
Alt text on imagesScreen readers can describe images
Use proper headingsCreates a clear page outline
Label form inputsUsers know what each input means
Use semantic tagsHelps navigation and meaning
accessibility.php
📝 Edit Code
👁 Live Preview
💡 Labels connected with for + matching id are a big accessibility win.
Chapter 24
∙ Chapter 24

SEO & Social Sharing

HTML in the <head> helps search engines and social apps understand your page. A good title and description increases clicks.

🔍Most important

<title> and <meta name="description"> are the basics for search results.

Open Graph tags improve previews when sharing links on WhatsApp, Facebook, LinkedIn, etc.

seo.php
📝 Edit Code
👁 Live Preview
💡 SEO is not only tags: clean headings, good text, and fast pages matter too.
Chapter 25
∙ Chapter 25

Best Practices & Validation

Clean HTML is easier to style, easier to maintain, and less buggy. These rules help you write professional HTML from day one.

Use semantic tags
Prefer <header>, <main>, <footer> instead of only divs.
Alt + labels
Always add alt on images and labels for inputs.
One h1
Use one main page title. Use h2/h3 for sections.
Separate CSS/JS
Keep HTML for structure. Use CSS for design and JS for behavior.
ℹ️Validate your pages to catch mistakes early (missing closing tags, invalid nesting, wrong attributes).
clean-html.php
📝 Edit Code
👁 Live Preview
💡 This is a solid starter template for most websites.
Chapter 26
∙ Chapter 26

Quotations & Citations

HTML has special tags for quotes, abbreviations, and time. These tags add meaning (semantics) and improve accessibility.

TagUseExample
<blockquote>Long quote (block)Multi-line quote
<q>Short quote (inline)He said “Hi”
<cite>Title of a work<cite>A Book</cite>
<abbr>Abbreviation<abbr title="HyperText Markup Language">HTML</abbr>
<time>Date/time<time datetime="2026-03-25">Mar 25, 2026</time>
quotes.php
📝 Edit Code
👁 Live Preview
💡 Hover the abbreviation to see the tooltip from title.
Chapter 27
∙ Chapter 27

Pre, Code & Keyboard

Use <pre> to preserve spacing and new lines. Use <code> for code snippets and <kbd> for keyboard shortcuts.

<pre>
Preserves whitespace exactly (great for code blocks).
<kbd>
Keys/shortcuts like Ctrl + S.
<samp>
Sample output from a program.
<var>
Variables in math or documentation.
pre-code.php
📝 Edit Code
👁 Live Preview
💡 Combine <pre> + <code> for formatted code blocks.
Chapter 28
∙ Chapter 28

CSS/JS & Favicons

Connect your CSS and JavaScript using <link> and <script>. A favicon makes your site look professional in the browser tab.

Quick rules

CSS: <link rel="stylesheet" href="style.css"> in the <head>.

JS: Prefer <script src="app.js" defer></script> so HTML loads first.

Favicon: <link rel="icon" href="/favicon.png">.

assets.php
📝 Edit Code
👁 Live Preview
💡 In real sites, move CSS/JS to separate files to keep HTML clean.
Chapter 29
∙ Chapter 29

Forms Advanced

Modern HTML forms support many input types and built-in validation. Often you can do a lot without JavaScript.

FeatureHowWhy
Validationrequired, minlength, patternStops bad data early
Mobile keyboardstype="email", type="tel"Right keyboard on phones
Grouping<fieldset> + <legend>Clarity + accessibility
Suggestions<datalist>Quick hints
forms-advanced.php
📝 Edit Code
👁 Live Preview
💡 Browser validation helps UX, but always validate again on the server in real apps.
Chapter 30
∙ Chapter 30

Figure, Picture & Lazy Images

Use <figure> + <figcaption> for images with captions, and <picture> when you need different sources (formats/sizes).

Add loading="lazy" to non-critical images to improve page speed.
figure-picture.php
📝 Edit Code
👁 Live Preview
💡 <picture> chooses the best source; CSS controls layout and size.
Chapter 31
∙ Chapter 31

Tables Properly

Use a caption, table sections, and header cells to make tables easier to understand (and accessible to screen readers).

tables-proper.php
📝 Edit Code
👁 Live Preview
💡 Use tables only for data. For layout, use CSS grid/flex.
Chapter 32
∙ Chapter 32

SVG & Canvas

SVG is vector graphics (crisp at any size). Canvas is a drawing surface controlled by JavaScript (great for games and charts).

graphics.php
📝 Edit Code
👁 Live Preview
💡 SVG elements are real DOM nodes. Canvas is pixels you redraw with code.
Chapter 33
∙ Chapter 33

Details & Dialog

Build simple UI with pure HTML: collapsible sections with <details> and modal popups with <dialog>.

interactive.php
📝 Edit Code
👁 Live Preview
💡 Use CSS to style <dialog> and its backdrop.
Chapter 34
∙ Chapter 34

Scripts & Noscript

For external JS files, prefer defer so HTML loads first. Use type="module" for modern JavaScript. Use <noscript> for graceful fallback.

scripts.php
📝 Edit Code
👁 Live Preview
💡 Don't block page loading: put JS at the end of body, or use defer for external files.
Chapter 35
∙ Chapter 35

Data & Microdata

Use data-* attributes to attach custom info to elements for JavaScript. Microdata adds extra meaning for things like people/products.

data-microdata.php
📝 Edit Code
👁 Live Preview
💡 Use data-* for your app logic. Microdata is optional and often handled by SEO tooling.
Chapter 36
∙ Chapter 36

Links Advanced

Links are more than just "go to another page". You can create phone/email links, download links, open in a new tab safely, and jump to sections on the same page.

🔗Beginner rules

New tab: use target="_blank" and add rel="noopener noreferrer" for security.

Same page: link to an element id like #contact.

Phone/email: use tel: and mailto:.

links-advanced.php
📝 Edit Code
👁 Live Preview
💡 If you use target="_blank", always add rel="noopener" for safety.
Chapter 37
∙ Chapter 37

Paths & URLs

A path tells the browser where to find a file (image, page, CSS, JS). Beginners often break links because of wrong relative paths.

TypeExampleMeaning
Absolute URLhttps://site.com/pageWorks from anywhere
Root-relative/assets/logo.pngFrom website root
Relativeimages/pic.jpgFrom current folder
Go up../css/style.cssOne folder up
⚠️Beginner warning: If your page is inside a folder, images/pic.jpg and /images/pic.jpg are not the same.
paths.php
📝 Edit Code
👁 Live Preview
💡 Open DevTools → Network: broken paths show 404 errors.
Chapter 38
∙ Chapter 38

Global Attributes

Global attributes can be used on almost any element. They help with styling (class), linking (id), accessibility, and interactivity.

id
Unique name on the page. Used for links (#id) and JavaScript.
class
Group elements for CSS styling (many elements can share a class).
title
Tooltip text on hover (don't rely on it for important info).
hidden
Hides an element without needing CSS.
contenteditable
Makes text editable by the user (use carefully).
tabindex
Controls keyboard focus order (use only when needed).
global-attrs.php
📝 Edit Code
👁 Live Preview
💡 Keep id unique. Repeating the same id breaks JS and links.
Chapter 39
∙ Chapter 39

Audio/Video Advanced

HTML media tags support posters, looping, multiple sources, and captions. Captions are important for accessibility.

🎬Important attributes

controls shows play/pause UI.

poster shows an image before video starts.

muted is often required for autoplay in browsers.

<track> adds captions/subtitles.

media-advanced.php
📝 Edit Code
👁 Live Preview
💡 Autoplay is usually blocked unless the video is muted.
Chapter 40
∙ Chapter 40

Iframes Security

Iframes embed another page inside your page. Real websites often block being embedded. Use security attributes like sandbox and good defaults like loading="lazy".

AttributeWhy
sandboxRestricts what the iframe can do (recommended for untrusted content)
loading="lazy"Loads iframe only when near the viewport
referrerpolicyControls referrer information sent
allowPermissions for camera, microphone, fullscreen, etc.
iframe-security.php
📝 Edit Code
👁 Live Preview
💡 sandbox without values is very strict. Add permissions only if needed.
Chapter 41
∙ Chapter 41

Template Element

The <template> tag stores HTML that is NOT shown until JavaScript clones it. This is useful for repeating UI like cards, rows, or list items.

template.php
📝 Edit Code
👁 Live Preview
💡 <template> content does not render until you use JavaScript.
Chapter 42
∙ Chapter 42

Forms Upload & Method

When you upload files, the form needs enctype="multipart/form-data". Also learn action, method, and different button types.

📁Beginner checklist

method="post" is used for sending data.

action is the URL that receives form data.

name on inputs becomes the key in submitted data.

forms-upload.php
📝 Edit Code
👁 Live Preview
💡 Without enctype="multipart/form-data", the file input will not send the file.
Chapter 43
∙ Chapter 43

Input Types & Validation

HTML has many input types: number, date, range, email, url, password. The browser can validate these automatically and show the right keyboard on mobile.

input-types.php
📝 Edit Code
👁 Live Preview
💡 Try submitting without an email to see built-in validation.
Chapter 44
∙ Chapter 44

Images: srcset & sizes

Use srcset and sizes so the browser downloads the best image for the user's screen. This makes sites faster on mobile.

ℹ️Simple idea: provide multiple image widths, and the browser picks the right one.
srcset.php
📝 Edit Code
👁 Live Preview
💡 Always keep alt. It helps accessibility and SEO.
Chapter 45
∙ Chapter 45

SEO: JSON-LD Basics

Structured data helps search engines understand your page (like "This is an article" or "This is a product"). The most common format is JSON-LD inside a script tag.

json-ld.php
📝 Edit Code
👁 Live Preview
💡 Use only correct structured data. Fake data can hurt trust.
Chapter 46
∙ Chapter 46

Accessibility: ARIA Basics

ARIA attributes help assistive technologies when HTML alone is not enough. First prefer semantic HTML. Use ARIA mainly to label controls and describe relationships.

⚠️Golden rule: Don't add ARIA if the semantic HTML already works.
aria.php
📝 Edit Code
👁 Live Preview
💡 Always ensure interactive elements are reachable with keyboard (Tab key).
Chapter 47
∙ Chapter 47

Mini Project: Semantic Page

Build a simple page using semantic elements used in real sites: header, nav, main, article, aside, and footer.

mini-project.php
📝 Edit Code
👁 Live Preview
💡 This structure is easy to style with CSS later.
Chapter 48
∙ Chapter 48

Head Deep Dive

The <head> contains important info for browsers and search engines: charset, viewport, title, description, icons, and social previews.

head-deep.php
📝 Edit Code
👁 Live Preview
💡 Your page can look the same but rank/share better with good head tags.
Chapter 49
∙ Chapter 49

Debugging & Validation

When HTML doesn't work, don't guess. Use debugging steps: validate HTML, inspect elements, and read console/network errors.

View Source
Check what HTML the browser actually received.
Inspect
See the real DOM and CSS. Great for layout issues.
Console
JavaScript errors show here.
Network
404/failed images, CSS, JS files appear here.
debugging.php
📝 Edit Code
👁 Live Preview
💡 Validate with an HTML validator to catch invalid tags and nesting.
Chapter 50
∙ Chapter 50

Performance Basics

Fast pages feel professional. HTML has simple performance helpers: lazy loading, proper image sizes, and non-blocking scripts.

TipHTML exampleWhy
Lazy imagesloading="lazy"Loads only when needed
Decode asyncdecoding="async"Better loading behavior
Non-blocking JS<script src="app.js" defer>HTML renders faster
Give sizeswidth + heightPrevents layout shift
performance.php
📝 Edit Code
👁 Live Preview
💡 Biggest speed win: smaller images + fewer heavy scripts.
Chapter 51
∙ Chapter 51

HTML HOME

This page is a complete HTML tutorial + reference. Use the left sidebar search to jump to any topic instantly.

Learn
Read a topic, then edit the live examples.
Practice
Try exercises and mini projects to build speed.
Reference
Use chapters like #taglist, #events, and #httpmethods.
Search
Typing in the sidebar search brings matches to the top.
ℹ️Tip: bookmark important anchors like #forms, #seo, and #performance.
Chapter 52
∙ Chapter 52

HTML Editors

You can write HTML in any text editor, but a code editor makes you faster with autocomplete, formatting, and live previews.

VS Code
Best beginner choice: extensions + Emmet + formatting.
DevTools
Inspect HTML/CSS, debug errors, test quickly.
Emmet
Type ul>li*5 and expand into HTML instantly.
Formatter
Keep code readable; consistent indentation matters.
Chapter 53
∙ Chapter 53

HTML Basic

A basic HTML page needs a doctype, <html>, <head> and <body>. Everything visible goes in the body.

📄Minimal HTML5 starter
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>My First Page</title>
</head>
<body>
  <h1>Hello HTML</h1>
  <p>This is a paragraph.</p>
</body>
</html>
Use semantic tags (like <header> and <main>) as your page grows.
Chapter 54
∙ Chapter 54

HTML Elements

An HTML element is the full thing: opening tag + content + closing tag (some elements are void/self-closing like <img>).

TypeExampleNotes
Normal<p>Text</p>Has opening + closing tags
Void<img>, <br>No closing tag
Nesting<a><span>...</span></a>Elements can contain other elements
⚠️Invalid nesting can break layouts (example: putting a block element inside an inline element).
Chapter 55
∙ Chapter 55

HTML Styles

HTML uses CSS for styling. The quickest way is the style attribute, but real projects prefer external CSS files.

🎨Inline style example
<h2 style="color:#00e5ff;margin:0">Styled heading</h2>
<p style="color:#7986cb">Inline styles work, but don't scale well.</p>
Prefer classes for styling: class="card" + CSS in a stylesheet.
Chapter 56
∙ Chapter 56

HTML CSS

There are 3 ways to add CSS: inline, internal <style>, and external <link>. External is best for real sites.

MethodExampleBest for
Inlinestyle="..."Small demos only
Internal<style>...</style>Single page prototypes
External<link rel="stylesheet" href="style.css">Production websites
Chapter 57
∙ Chapter 57

HTML Favicon

A favicon is the small icon shown in the browser tab. It helps branding and looks more professional.

🔗Favicon tags
<link rel="icon" href="/favicon.png">
<!-- optional -->
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
ℹ️Make sure your favicon path is correct. Broken icons show as 404 in DevTools → Network.
Chapter 58
∙ Chapter 58

HTML Page Title

The <title> shows in the browser tab and is one of the most important SEO signals for the page.

🔖Good title rules
  • 1Put the main keyword first (example: HTML Tutorial).
  • 2Keep it readable; avoid keyword stuffing.
  • 3Make each page title unique.
Chapter 59
∙ Chapter 59

HTML Buttons

Use <button> for actions, and <a> for navigation. Always set the type inside forms.

Button typeWhat it doesExample
submitSubmits the formtype="submit"
buttonDoes nothing by default (use JS)type="button"
resetResets form fieldstype="reset"
⚠️Inside a form, a <button> defaults to type="submit". Set type="button" for JS buttons.
Chapter 60
∙ Chapter 60

HTML Layout

HTML layout is mostly semantic structure. CSS (grid/flex) handles the visual layout.

<header>
Top area: logo, nav, hero.
<main>
Unique main content of the page.
<aside>
Sidebar/related content.
<footer>
Bottom area: links, copyright.
ℹ️See #miniproject for a full semantic page structure example.
Chapter 61
∙ Chapter 61

HTML Responsive

Responsive design means the page works on phones, tablets, and desktops. HTML starts it with the viewport meta tag.

📱Responsive essentials

<meta name="viewport" content="width=device-width, initial-scale=1">

Use flexible layouts (CSS grid/flex), responsive images (srcset), and avoid fixed widths.

Use max-width: 100% on images/videos/iframes to prevent horizontal scrolling.
Chapter 62
∙ Chapter 62

HTML Emojis

Emojis work automatically if your page uses UTF-8: <meta charset="UTF-8">. You can also use numeric entities.

😁Example

Direct: 😀 🚀 🎉

Entity: &#128640; → 🚀

Chapter 63
∙ Chapter 63

HTML Charsets

Charset tells the browser how to decode text. Use UTF-8 for modern websites. Put it near the top of <head>.

🔑Recommended

<meta charset="utf-8">

⚠️Wrong charset can cause weird symbols (�) instead of readable text.
Chapter 64
∙ Chapter 64

HTML URL Encode

URLs can't contain spaces and some special characters. Encoding replaces them with safe sequences like %20.

CharacterEncodedExample
space%20Hello%20World
&%26a%26b
?%3Fq%3F
ℹ️In JavaScript, use encodeURIComponent() for query parameter values.
Chapter 65
∙ Chapter 65

HTML vs XHTML

HTML5 is forgiving. XHTML is stricter XML-style markup (must be well-formed). Most modern web pages use HTML5.

HTML5
Forgiving; browsers try to fix mistakes.
XHTML
Strict; invalid syntax can break parsing.
ℹ️Even in HTML5, writing valid, clean HTML is still a best practice.
Chapter 66
∙ Chapter 66

HTML Form Attributes

Form attributes control where data goes and how it's sent. They live on the <form> tag.

AttributeMeaningExample
actionURL that receives dataaction="/signup"
methodHTTP methodmethod="post"
enctypeEncoding (uploads)multipart/form-data
autocompleteBrowser autofillautocomplete="on"
Chapter 67
∙ Chapter 67

HTML Form Elements

Forms are built from inputs, selects, textareas, and buttons. Use <label> for accessibility.

<input>
Text, email, password, file, etc.
<select>
Dropdown options.
<textarea>
Multi-line text input.
<button>
Actions: submit/reset/button.
Use <fieldset> + <legend> to group related inputs.
Chapter 68
∙ Chapter 68

HTML Input Attributes

Input attributes add constraints and improve UX (validation, keyboards, autofill). They also help accessibility.

AttributeUseExample
requiredMust be filledrequired
placeholderHint textplaceholder="Email"
min / maxNumeric boundsmin="1"
patternRegex patternpattern="\\d{10}"
autocompleteAutofill hintautocomplete="email"
⚠️Client-side validation helps UX, but always validate again on the server.
Chapter 69
∙ Chapter 69

HTML Plug-ins

Modern HTML5 supports audio/video without plug-ins. Legacy plug-ins like Flash are obsolete and blocked in modern browsers.

ℹ️Prefer <video>, <audio>, and modern embeds. Avoid old <embed>/<object> unless you have a specific need.
Chapter 70
∙ Chapter 70

HTML YouTube

YouTube videos are embedded using an <iframe>. Use lazy loading for performance.

🎥Embed example
<iframe
  width="560" height="315"
  loading="lazy"
  style="border:0;border-radius:12px;max-width:100%"
  src="https://www.youtube.com/embed/VIDEO_ID"
  allowfullscreen></iframe>
Chapter 71
∙ Chapter 71

HTML Web APIs

Web APIs are JavaScript features built into the browser (not HTML tags). HTML provides the UI; JS APIs add advanced capabilities.

Geolocation
Get device location (with permission).
Web Storage
Store small data in the browser.
Web Workers
Run heavy tasks off the main thread.
SSE
Server sends updates to the browser.
Chapter 72
∙ Chapter 72

HTML Geolocation

Geolocation is a browser API (JavaScript). It requires user permission and usually works only on HTTPS.

📍JS example
navigator.geolocation.getCurrentPosition(
  (pos) => console.log(pos.coords.latitude, pos.coords.longitude),
  (err) => console.error(err)
);
⚠️Never request location unless you truly need it. Explain why you need it.
Chapter 73
∙ Chapter 73

HTML Drag & Drop

Drag and drop can be built using the HTML Drag and Drop API, but many apps use simpler pointer/touch interactions for better mobile support.

ℹ️For learning: look up events like dragstart, dragover, and drop. For production: test well on touch devices.
Chapter 74
∙ Chapter 74

HTML Web Storage

Web Storage provides localStorage (persistent) and sessionStorage (tab session). Great for small preferences.

💾Example
localStorage.setItem('theme', 'dark');
const theme = localStorage.getItem('theme');
⚠️Don't store secrets (passwords/tokens) in localStorage.
Chapter 75
∙ Chapter 75

HTML Web Workers

Web Workers run JavaScript in a background thread so heavy work doesn't freeze the UI.

ℹ️Workers can't access the DOM directly. Communicate via postMessage.
Chapter 76
∙ Chapter 76

HTML SSE (Server-Sent Events)

SSE lets the server stream updates to the browser over a single HTTP connection. It's great for live notifications and dashboards.

📶JS example
const es = new EventSource('/events');
es.onmessage = (e) => console.log('Update:', e.data);
Chapter 77
∙ Chapter 77

HTML Quiz

Test yourself after every 5–10 topics. Quizzes help you remember tags and rules faster.

Answer without Google first, then verify with an HTML validator + DevTools.
Chapter 78
∙ Chapter 78

HTML Exercises

Exercises are small tasks like “create a form with labels” or “build a table with a caption”. Do them with a timer.

Exercise 1
Build a nav bar with 4 links.
Exercise 2
Create a contact form with labels + required fields.
Exercise 3
Make a responsive image using srcset.
Exercise 4
Write semantic layout: header, main, footer.
Chapter 79
∙ Chapter 79

HTML Challenges

Challenges are bigger than exercises: build a mini landing page, a resume page, or a product card layout using only semantic HTML.

ℹ️Try building without CSS first. Then style it with CSS after the structure is correct.
Chapter 80
∙ Chapter 80

HTML Syllabus

A solid HTML syllabus: structure → text → links/media → tables/lists → forms → semantics → SEO/a11y → performance.

Follow the sidebar order; it is already arranged from beginner to advanced.
Chapter 81
∙ Chapter 81

HTML Study Plan

A simple plan: 30–45 minutes/day. Learn 1 topic, edit the example, and write your own version from memory.

WeekFocusGoal
1Basics + textWrite a full page without copy/paste
2Links/media + tables/listsBuild a small blog-like page
3Forms + semanticsBuild a signup/contact page
4SEO + a11y + perfMake it shareable + accessible
Chapter 82
∙ Chapter 82

HTML Interview Prep

Common interview areas: semantic HTML, forms + validation, accessibility (labels/aria), and performance basics.

ℹ️Practice explaining why you chose a tag (example: <button> vs <a>).
Chapter 83
∙ Chapter 83

HTML Certificate

A certificate is useful only if you can build real pages. Focus on projects: semantic layout, forms, and responsive images.

Chapter 84
∙ Chapter 84

HTML Summary

HTML gives structure. CSS gives style. JavaScript gives behavior. Learn semantic HTML first, then enhance with CSS/JS.

Write clean HTML: semantic tags, good headings, alt text, labels, and valid nesting.
Chapter 85
∙ Chapter 85

HTML Tag List

A quick list of common tags you will use daily. Use this as a memory refresh.

CategoryTags
Text<h1>…<h6>, <p>, <strong>, <em>, <small>
Links/media<a>, <img>, <video>, <audio>, <iframe>
Layout<header>, <nav>, <main>, <section>, <article>, <footer>
Forms<form>, <label>, <input>, <textarea>, <select>, <button>
Chapter 86
∙ Chapter 86

HTML Browser Support

Most core HTML works everywhere. Newer elements/attributes may differ across browsers. Always test on at least Chrome + Firefox + Safari.

ℹ️Tip: progressive enhancement — build the basic experience first, then add advanced features.
Chapter 87
∙ Chapter 87

HTML Events

Events are JavaScript hooks for user actions like clicks and typing. HTML provides attributes (like onclick), but modern code uses addEventListener.

EventWhen it fires
clickUser clicks an element
inputUser changes an input value
submitForm is submitted
keydownA key is pressed
loadPage/resources finished loading
Chapter 88
∙ Chapter 88

HTML Doctypes

The doctype tells the browser to use standards mode. For HTML5, it's always the same.

📝HTML5 doctype

<!doctype html>

ℹ️Always keep the doctype as the first line of your HTML file.
Chapter 89
∙ Chapter 89

HTML Lang Codes

Set lang on the <html> element for accessibility and proper text handling. Use BCP47 language tags.

ExampleMeaning
enEnglish
en-USEnglish (United States)
hi-INHindi (India)
Correct lang improves screen reader pronunciation.
Chapter 90
∙ Chapter 90

HTTP Messages

HTTP messages are requests and responses between browser and server. HTML pages are delivered in HTTP responses.

Request
Method + URL + headers (+ body).
Response
Status code + headers + body (HTML/CSS/JS).
ℹ️Use DevTools → Network to see real requests/responses.
Chapter 91
∙ Chapter 91

HTTP Methods

Methods describe what you want to do. Forms mainly use GET and POST.

MethodTypical use
GETFetch data / search (form values in URL)
POSTCreate/submit data (form values in request body)
PUTReplace an existing resource
PATCHUpdate part of a resource
DELETERemove a resource
Chapter 92
∙ Chapter 92

PX to EM Converter

Convert pixels to em units: em = px / base. A common base is 16px.

🔄Converter
Result
1em
Chapter 93
∙ Chapter 93

Keyboard Shortcuts

Use <kbd> to display shortcuts in documentation and tutorials.

ShortcutAction
Ctrl + SSave
Ctrl + FFind
Ctrl + ZUndo
Ctrl + Shift + ZRedo
PreviousBack to Home
🎉 HTML Tutorial Complete (50 topics)!
Next UpCSS Basics →