HTML Tutorial
Learn HTML from zero to professional. 106 hands-on lessons with a live editor in every lesson, quizzes and real projects.
Start learning →
of lessons completed
Getting Started
- What Is HTML? A beginner-friendly introduction to HTML. Learn what HTML does, how browsers read it, and write your very first lines of markup.
- A Short History of HTML How HTML grew from a short list of tags at CERN into today's Living Standard, what "HTML5" really means, and why every page still starts with a doctype.
- Your First Web Page Set up a code editor, save your first .html file and open it in a browser. Learn the basic skeleton that every HTML document starts with.
- Viewing Source and Using DevTools Learn the difference between a page's source and its live DOM, inspect and edit elements in DevTools, use the console, test mobile sizes and spot repaired HTML.
- Elements and Tags Understand the difference between tags and elements, how to nest elements correctly, and which special elements never need a closing tag.
- Attributes Learn how attributes add extra information to HTML elements. Build links with href, show images with src and alt, and use global attributes like id, class, title and lang.
- Headings and Paragraphs Structure your text with the six heading levels, paragraphs, line breaks and thematic breaks, and learn why a logical heading outline matters for readers and search engines.
- HTML Editors, Emmet and Comments Pick a code editor for HTML, type faster with Emmet abbreviations, and learn how HTML comments work, what they are good for and what never to put in them.
Text Content
- Formatting Text Format text by meaning, not looks. Learn strong vs b, em vs i, plus u, s, mark, small, sub, sup, ins and del, with clear rules for when to use each one.
- Quotations, Citations and Abbreviations Quote and credit other people's words with blockquote, q and cite, explain abbreviations and terms with abbr and dfn, and handle contact details and text direction.
- Code, Keyboard Input and Program Output Mark up code snippets, keyboard shortcuts, program output and variables with code, pre, kbd, samp and var, and learn to escape < and & inside code samples.
- HTML Entities Learn when you need HTML entities, how named, decimal and hex references work, how to use no-break spaces and soft hyphens, plus a table of common ones.
- Symbols and Emojis Add math signs, arrows, currency symbols, Greek letters and emoji to your pages with Unicode, and make sure they display everywhere and work with screen readers.
- Character Encoding and UTF-8 Understand bytes vs characters, ASCII, Windows-1252, Unicode and UTF-8, where to put meta charset, and how to diagnose and fix garbled text known as mojibake.
- Times, Data Values and Ruby Text Give dates, times and numbers a machine-readable form with time and data, control line breaks in long words with wbr, and annotate East Asian text with ruby.
Links and Navigation
- Links in Depth Master the HTML a element. Learn the kinds of href values, how to write link text people can trust, image links, the title attribute and when to use a button.
- File Paths and URLs Learn how URLs are built and how browsers resolve relative paths like ./ and ../, root-relative paths and absolute URLs, with folder examples and the base element.
- Link Targets and Page Jumps Control where links open with target, keep new tabs safe with rel="noopener noreferrer", and jump to exact sections with fragment links, :target and back-to-top links.
- Email, Phone and Download Links Create email links with subject and body, phone and SMS links, and download links. Learn hreflang, type and the rel values nofollow, sponsored and ugc.
- Building Navigation Menus Build accessible navigation with the nav element and lists. Mark the current page with aria-current, and add breadcrumbs, skip links, pagination and footer links.
- URL Encoding Learn why URLs need percent-encoding, which characters are reserved, %20 versus + for spaces, how UTF-8 encodes non-English text, and how encodeURIComponent works.
Lists
- Lists Learn how to build bulleted and numbered lists with ul, ol and li, how to choose the right one, and how to change bullets and numbers with list-style-type.
- Ordered List Options Control numbering in HTML ordered lists. Start at any number, count down with reversed, choose letters or Roman numerals with type, and set item numbers with value.
- Description Lists Use dl, dt and dd to build glossaries, FAQs and key-value details. Learn how to group several terms and descriptions, wrap groups in div and style them.
- Nested Lists Learn how to nest HTML lists correctly inside li elements, build outlines, mix ordered and unordered lists, number items 1.1 and 1.2, and avoid common mistakes.
Tables
- Tables Build your first HTML tables with table, tr, td and th. Learn how rows and cells form a grid, when a table is the right choice, and why tables are never for layout.
- Table Headers, Sections and Captions Give your tables real structure with th and scope, a caption that names the table, and thead, tbody and tfoot row groups for headers, data and totals.
- Spanning Rows and Columns Merge table cells with colspan and rowspan. Learn to plan the grid on paper first, count cells correctly, and avoid the overlapping cells that break table layouts.
- Column Groups Use colgroup and col to describe and style whole table columns. Learn the span attribute, where column groups go, and the four CSS properties that work on columns.
- Styling Tables with CSS Turn plain HTML tables into clear, readable data with CSS. Borders and border-collapse, padding, alignment, zebra rows, hover, sticky headers and scrolling on small screens.
- Accessible Tables Make data tables work for screen-reader users. Connect cells to headers with scope and the headers attribute, describe tables well, and avoid nested and layout tables.
Images and Media
- Images Add images with the HTML img element. Write useful alt text, set width and height to stop layout shift, pick the right format and lazy-load images.
- Responsive Images Serve the right image to every screen with srcset, sizes and the picture element. Learn w and x descriptors, format fallbacks and art direction.
- Background Images in HTML Pages Add background images with CSS, control size, position and repeat, layer gradients for readable text, and learn when to use img instead of a background.
- Figures and Captions Use figure and figcaption to caption images, code samples, quotes and charts. Learn when content is a figure and how alt text and captions differ.
- Image Maps Make parts of one image clickable with map and area. Learn rect, circle and poly coordinates, accessible alt text, and a responsive SVG alternative.
- Favicons and App Icons Add a favicon with link rel="icon", use SVG and dark-mode icons, and set up apple-touch-icon and a web app manifest. A minimal, modern set of icon files.
- Video Embed video with the HTML video element. Use controls, multiple sources, a poster image, autoplay rules, muted, loop, playsinline, preload and sizing.
- Audio Play sound with the HTML audio element. Add controls, offer MP3 and Ogg sources, understand autoplay rules, loop and mute, and start audio from JavaScript.
- Captions and Subtitles Add captions and subtitles to video with the track element and WebVTT files. Learn kind, srclang, label and default, cue timing, settings and styling.
- Iframes Embed one web page inside another with the HTML iframe element. Learn src, srcdoc, title, sandbox, allow, loading="lazy", referrerpolicy and framing rules.
- Embedding Videos, Maps and Other Content Embed videos, maps and other third-party content with iframes. Make embeds responsive, protect privacy, and see where embed and object fit today.
Page Structure and Layout
- Block and Inline Elements Learn the difference between block and inline elements, how they flow on the page, which elements can nest inside which, and when inline-block is the right choice.
- Div and Span Learn what div and span do, how they group content for CSS and JavaScript, and when a semantic element like section, nav or button is the better choice.
- Classes Use the class attribute to group elements for CSS and JavaScript. Learn multiple classes, class selectors, classList methods and naming conventions that scale.
- IDs Give elements unique ids for page jumps, form labels and JavaScript. Learn the rules for valid ids, why to be careful with id selectors in CSS, and getElementById.
- Semantic Elements Learn the HTML semantic elements header, nav, main, article, section, aside, footer, hgroup and search, and how they create landmarks for assistive tech.
- Page Layout Build a complete page layout from semantic HTML elements, then arrange it with CSS Flexbox and Grid, including a footer that sticks to the bottom.
- Responsive Web Design Make pages that work on every screen. Learn the viewport meta tag, fluid widths, flexible images, media queries, mobile-first CSS and fluid type with clamp().
The Head, Metadata and SEO
- The head Element Learn what belongs in the HTML head element (title, meta, link, style, script, base and noscript) and the order that helps pages load fast and read well.
- Page Titles and Descriptions Write page titles and meta descriptions that work for people and search results. Learn about length, uniqueness, branding and how search engines use them.
- Meta Tags A practical guide to HTML meta tags: charset, viewport, description, robots, theme-color, color-scheme, referrer and http-equiv, plus the old tags you can drop.
- Social Sharing Previews Control how your pages look when shared on social networks and chat apps with Open Graph and X card tags. Learn image sizes, fallbacks and how to test.
- Structured Data Describe your pages to machines with schema.org structured data. Write JSON-LD and microdata, learn about rich results, and validate your markup.
- Loading Resources Efficiently Speed up your pages from the HTML head. Learn render-blocking resources, defer and async, preconnect, preload, modulepreload, prefetch and fetchpriority.
- HTML SEO Checklist A practical HTML SEO checklist: titles, headings, canonical URLs, robots rules, hreflang, links, images and sitemaps, with a script that audits a page.
CSS and JavaScript in HTML
- The style Attribute Learn the HTML style attribute and CSS declaration syntax, try common properties for text, color, spacing and borders, and see when inline styles are the wrong tool.
- Colors Write colors with names, hex codes, rgb() and hsl(), add transparency with alpha, reuse colors with currentColor and check text contrast for readability.
- Adding CSS to HTML Compare the three ways to add CSS to HTML (inline, the style element and external stylesheets), see how the cascade picks a winner and load CSS per media type.
- Adding JavaScript Add JavaScript to HTML with inline and external script elements, choose where to place them, compare defer, async and type="module", and use noscript fallbacks.
- Event Attributes and Event Listeners Respond to clicks, typing and other events with HTML event attributes like onclick, learn why addEventListener is better, and use the event object.
- The Document Object Model Learn how the browser turns HTML into the DOM tree, find elements with querySelector, change text safely, create elements and work with attributes and classList.
Forms
- Forms Learn how HTML forms collect input, how the browser turns fields into name=value pairs, when to use GET or POST, and how to handle submit in JavaScript.
- Input Types A guided tour of every HTML input type, from text, email and number to date, color, file and range, with what each one does on desktop and mobile.
- Labels, Fieldsets and Legends Give every form control a proper name with label, group related fields with fieldset and legend, and learn how browsers work out a control's accessible name.
- Checkboxes and Radio Buttons Learn how checkboxes and radio buttons submit their values, how to build groups, how to make a choice required, and how to restyle them with accent-color.
- Drop-downs and Suggestions Build drop-down menus with select, option and optgroup, allow multiple choices, add a required placeholder option, and offer typing suggestions with datalist.
- Text Areas and Buttons Collect longer text with textarea (rows, cols, maxlength, wrap) and master buttons, including submit, reset and button types, button vs input, and formaction.
- Input Attributes Fine-tune form inputs with value, placeholder, readonly, disabled, min, max, step, pattern, autocomplete, inputmode, enterkeyhint and other input attributes.
- Form Attributes Configure the form element itself with action, method, target, enctype for file uploads, autocomplete, novalidate, name and accept-charset.
- Form Validation Let the browser check input with required, type, min, max, pattern and length, style errors with :user-invalid, and add custom rules with the validation API.
- Output, Meter and Progress Show calculated results with output, measurements within a known range with meter, and task completion with progress, including indeterminate progress bars.
Interactive Elements
- Collapsible Sections with Details Build collapsible sections and accordions with details and summary, open them by default, group them with name, react to the toggle event and style the marker.
- Dialogs and Modals Build accessible modal and non-modal dialogs with the dialog element, showModal and close, method="dialog" forms, returnValue, ::backdrop and focus handling.
- Popovers Use the popover attribute to build menus, info panels and notifications. Learn auto vs manual popovers, popovertarget, toggle events and when to use dialog.
- Global Attributes Learn the HTML global attributes that work on every element, from id, class and lang to hidden, inert, contenteditable, tabindex, dir and translate.
- Custom Data Attributes Store your own data on HTML elements with data-* attributes, read and write it through JavaScript's dataset, and style elements with CSS attribute selectors.
- Templates and Web Components Reuse markup with the template element, then build your own HTML tags with custom elements, encapsulate styles with shadow DOM and fill them using slots.
- Editable Content: contenteditable, spellcheck and inputmode Make any element editable with contenteditable, control spell checking, and pick the right mobile keyboard with inputmode, enterkeyhint and autocapitalize.
Graphics
- SVG Basics Draw sharp, scalable graphics with inline SVG. Learn the coordinate system and viewBox, the basic shapes, fill and stroke, and when to use img instead.
- SVG Paths, Text and Gradients Draw any shape with SVG path commands, add real text, fill shapes with linear and radial gradients, reuse parts with g and use, and make SVG accessible.
- SVG Clipping, Masks, Filters and Animation Cut shapes with clipPath, fade them with masks, blur, tint and distort them with SVG filter primitives, and animate SVG with SMIL elements or CSS animations.
- Canvas Basics Get started with the HTML canvas element. Draw rectangles with the 2D context, set fill and stroke styles, size the canvas sharply and provide fallback content.
- Drawing and Animating with Canvas Go beyond rectangles on the HTML canvas. Draw paths and arcs, write text, place images with drawImage, paint gradients and animate with requestAnimationFrame.
- Math with MathML Write mathematical formulas directly in HTML with MathML. Learn the math element, mi, mn, mo, mrow, fractions, powers, roots, display math and browser support.
Web APIs
- Introduction to Web APIs Learn what browser Web APIs are, how to detect whether a feature exists, how permission prompts and secure contexts work, and how to read promise-based code.
- Geolocation Get the user's location with the Geolocation API. Learn getCurrentPosition, watchPosition, the options object, every error code, permissions and HTTPS.
- Drag and Drop Build drag and drop with HTML and JavaScript. Learn the draggable attribute, the drag events, dataTransfer, drop zones and how to accept dropped files.
- Files, File Uploads and the FileReader API Let users pick files with input type=file, read them with File, Blob and FileReader, preview images with object URLs and send uploads with FormData.
- Web Storage Save data in the browser with localStorage and sessionStorage. Learn the API, storing objects as JSON, the storage event, size limits and privacy rules.
- Web Workers Keep your page responsive with Web Workers. Learn how to start a worker, exchange messages with postMessage, handle errors and stop a worker with terminate.
- Intersection, Resize and Mutation Observers Watch elements without polling: IntersectionObserver for lazy reveal and sticky detection, ResizeObserver for size changes, MutationObserver for DOM edits.
- History, Location and URL APIs Read and change the address bar from JavaScript. Learn the URL and URLSearchParams classes, the location object, pushState and popstate, and hash-based routing.
- Server-Sent Events Stream live updates from a server with Server-Sent Events. Learn EventSource, the text/event-stream format, named events, IDs and automatic reconnection.
- WebSockets Learn the WebSocket API for two-way, real-time messaging. Open a connection, send and receive data, handle close codes, and choose between WebSockets, SSE and fetch.
- IndexedDB Store large amounts of structured data in the browser with IndexedDB. Learn databases, versions, object stores, transactions, indexes, cursors and key ranges.
- Cross-Document Messaging with postMessage Send data between a page and its iframes or popups with window.postMessage. Learn targetOrigin, event.origin checks, structured cloning and MessageChannel.
- Cross-Origin Requests and CORS Understand the same-origin policy and CORS. Learn simple and preflighted requests, credentials, opaque responses, the crossorigin attribute and how to read CORS errors.
- Progressive Web Apps: Manifest and Service Workers Turn a website into an installable app. Write a web app manifest, register a service worker, cache files for offline use and pick a caching strategy.
- Web Share, Clipboard and Notifications APIs Share content through the system share sheet, copy and paste with the async Clipboard API, and ask for Notification permission the right way, with fallbacks.
- Page Visibility, Fullscreen and Screen Wake Lock React when a tab is hidden with the Page Visibility API, take over the screen with the Fullscreen API, and keep a device awake with Screen Wake Lock.
- Camera, Microphone and MediaRecorder Capture live video and audio with getUserMedia, handle permissions and errors, record streams with MediaRecorder, and play back or download the result.
- Web Audio API Basics Generate and shape sound with AudioContext, oscillators, gain nodes and filters. Build a small synthesizer and draw its waveform with an analyser.
- Speech Synthesis and Speech Recognition Make the browser speak with speechSynthesis and listen with SpeechRecognition. Pick voices, control rate and pitch, handle events, and design for privacy.
Accessibility and Best Practices
- Accessibility Basics Learn who accessibility helps, how screen readers read your HTML, and the habits that matter most, from semantic elements and alt text to labels and contrast.
- ARIA Roles, States and Properties Learn when ARIA helps and when it hurts. Use roles, accessible names, descriptions, aria-expanded and live regions correctly, following the first rule of ARIA.
- Keyboard Access and Focus Make every control reachable without a mouse. Learn tab order, tabindex 0 and -1, visible focus with :focus-visible, skip links, inert and focus management.
- HTML Style Guide Write HTML that is easy to read and maintain, with conventions for the doctype, lowercase names, quoting, indentation, optional tags, file names and comments.
- Validating Your HTML Check your markup with the W3C Nu HTML Checker and editor linters, fix the most common validation errors, and see how browsers quietly repair broken HTML.
- HTML vs XHTML Learn how HTML and XHTML differ, the strict rules of the XML syntax, why the MIME type decides how a page is parsed, and old versus modern doctypes.
- Deprecated and Obsolete Features Recognize obsolete HTML such as font, center, big, tt, acronym, frames, marquee and presentational attributes, and learn their modern replacements.
- Fast-Loading HTML Make pages load fast with lean HTML, image dimensions, lazy loading, non-blocking scripts, a smaller DOM, compression and caching, measured by Core Web Vitals.
- HTML Security: CSP, sandbox and Subresource Integrity Harden your pages with HTML features: a Content-Security-Policy meta tag, the iframe sandbox attribute, Subresource Integrity hashes and rel=noopener on links.
- HTML Email Basics Learn how HTML email differs from web pages. Build table-based layouts, use inline styles, make bulletproof buttons and plan for the limits of email clients.
Projects
- Project: Personal Profile Page Build a complete personal profile page with HTML and a little CSS. Add a photo, an introduction, skill lists, quick facts, contact links and a footer, step by step.
- Project: Blog Article Mark up a complete blog post with semantic HTML. Use article, header, time, a table of contents, figure, blockquote, aside and footer, then lay it out with CSS.
- Project: Accessible Contact Form Build an accessible contact form step by step with labels, fieldsets, hints, validation and clear error messages, plus a submit handler that shows the data.
- Project: Responsive Landing Page Build a complete responsive landing page with semantic HTML and CSS. Create a header, hero, features grid, pricing table, FAQ accordion, footer and media queries.
- Project: Event Page Build a complete event page in HTML with machine-readable dates, a schedule table, speaker cards, a static venue map and an accessible registration form.
Practice and Review
- HTML Cheat Sheet A one-page HTML cheat sheet covering the document skeleton, text, links, lists, images, media, tables, forms, interactive elements and the head, with live examples.
- HTML Practice Exercises Practice HTML with 26 graded exercises, from headings and links to tables, forms, dialogs and accessibility fixes. Each has a live starter editor and a solution.
- HTML Interview Questions Prepare for front-end interviews with 36 HTML questions and clear answers, grouped by level, covering semantics, forms, media, accessibility, performance and security.