Skip to content
Laviyx Learn

Try

HTML Cheat Sheet

Page skeleton, text, links, images, lists, tables, forms, semantic layout, media and accessibility essentials.

Updated

Page skeleton#

HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Page title | Site name</title>
    <meta name="description" content="One or two sentences for search results.">
    <link rel="stylesheet" href="styles.css">
    <script src="app.js" defer></script>
  </head>
  <body>
    <header>...</header>
    <main>...</main>
    <footer>...</footer>
  </body>
</html>

Text#

ElementUse
<h1> to <h6>Headings: one h1, no skipped levels
<p>Paragraph
<br> / <hr>Line break in content / change of topic
<strong> / <em>Important / stressed
<b> / <i>Keyword / alternate voice, no extra importance
<mark>, <small>, <del>, <ins>, <s>Highlight, fine print, edits, no longer accurate
<sub> / <sup>Subscript / superscript
<code>, <kbd>, <samp>, <var>, <pre>Code, keys, program output, variables, preformatted
<blockquote> / <q> / <cite>Long quote / inline quote / title of a work
<abbr title="...">Abbreviation
<time datetime="2026-10-24">Machine-readable date
HTML
<a href="https://example.com">External</a>
<a href="about.html">Same folder</a>
<a href="../index.html">Parent folder</a>
<a href="/contact">Site root (needs a server)</a>
<a href="#pricing">Section on this page</a>
<a href="mailto:hello@example.com">Email</a>
<a href="tel:+919876543210">Call</a>
<a href="report.pdf" download>Download (PDF)</a>
<a href="https://example.com" target="_blank">Opens in a new tab</a>

<img src="photo.jpg" alt="What the image shows" width="800" height="600" loading="lazy">
<img src="divider.png" alt="">                       <!-- decorative -->

<img src="photo-800.jpg"
     srcset="photo-400.jpg 400w, photo-800.jpg 800w, photo-1600.jpg 1600w"
     sizes="(max-width: 600px) 100vw, 600px" alt="..." width="800" height="600">

<figure>
  <img src="chart.png" alt="Sales doubled from 2024 to 2026">
  <figcaption>Figure 1: Sales by year.</figcaption>
</figure>

Lists and tables#

HTML
<ul><li>Unordered</li></ul>
<ol start="3" reversed type="a"><li>Ordered</li></ol>
<dl><dt>Term</dt><dd>Description</dd></dl>

<table>
  <caption>Exam results</caption>
  <thead><tr><th scope="col">Name</th><th scope="col">Marks</th></tr></thead>
  <tbody><tr><th scope="row">Asha</th><td>92</td></tr></tbody>
  <tfoot><tr><td colspan="2">Average: 92</td></tr></tfoot>
</table>

Forms#

HTML
<form action="/signup" method="post">
  <label for="email">Email</label>
  <input id="email" name="email" type="email" required>

  <fieldset>
    <legend>Plan</legend>
    <label><input type="radio" name="plan" value="free" checked> Free</label>
    <label><input type="radio" name="plan" value="pro"> Pro</label>
  </fieldset>

  <label><input type="checkbox" name="terms" required> I accept the terms</label>

  <select name="city" required>
    <option value="">Choose a city</option>
    <option>Pune</option>
  </select>

  <textarea name="message" rows="4"></textarea>
  <button type="submit">Sign up</button>
</form>
Input typeFor
text, email, password, tel, url, searchText with the right keyboard and checks
number, rangeAmounts (min, max, step)
date, time, datetime-local, monthPickers
checkbox, radioChoices (radios share a name)
file, hidden, colorUploads, hidden values, colour picker

Validation: required, minlength, maxlength, min, max, step, pattern="[0-9]{6}", novalidate on the form. Always validate on the server too.

Semantic layout#

ElementMeaning
<header> / <footer>Intro / closing content of the page or a section
<nav>Major navigation links
<main>The main content (one per page)
<article>Self-contained content: post, card, comment
<section>Themed group with a heading
<aside>Related side content
<div> / <span>No meaning: styling and scripting only

Media and interactive elements#

HTML
<video controls width="640" height="360" poster="poster.jpg">
  <source src="clip.webm" type="video/webm">
  <source src="clip.mp4" type="video/mp4">
  <track kind="captions" src="clip.en.vtt" srclang="en" label="English" default>
</video>
<audio controls src="sound.mp3"></audio>
<iframe src="https://example.com/embed" title="Describe the content" loading="lazy" sandbox></iframe>

<details name="faq" open><summary>Question</summary><p>Answer</p></details>
<dialog id="d"><form method="dialog"><button>Close</button></form></dialog>
<button popovertarget="tips">Tips</button><div id="tips" popover>...</div>

Accessibility essentials#

  • lang on <html>, a unique <title>, one <h1> and logical headings.
  • Alt text on images (alt="" if decorative); captions on video.
  • A <label> for every field; <fieldset>/<legend> for groups.
  • Real <button> and <a href> elements; visible focus; never div buttons.
  • aria-label for icon-only buttons; aria-expanded, aria-current for state; aria-hidden="true" for decorative icons.

Character references#

WriteFor
&lt; &gt; &amp;< > &
&quot; &apos;Quotes inside attributes
&nbsp;Non-breaking space
&copy; &#8377;© ₹

Want the full explanations? Go to the Learn HTML course →