Home › HTML Tutorial › All commands
All commands
Every command of this course: name, detailed description, syntax and example code.
Every command used in this course, with its name, a detailed description, the syntax and an example.
h1 p a href img alt ul ol table input label requiredh1
Definition: Defines the main heading of the page. Use one per page.
Syntax:
<h1>Heading text</h1>
Example:
<h1>Welcome</h1>p
Definition: Defines a paragraph of text.
Syntax:
<p>Text</p>
Example:
<p>Hello, web!</p>a
Definition: Creates a hyperlink to another page or resource.
Syntax:
<a href="URL">link text</a>
Example:
<a href="https://example.com">Visit</a>href
Definition: Attribute of a that sets where the link goes.
Syntax:
<a href="URL">text</a>
Example:
<a href="https://example.com">Go</a>img
Definition: Embeds an image in the page.
Syntax:
<img src="file" alt="description">
Example:
<img src="x.png" alt="A sleeping cat">alt
Definition: Text description of an image, shown if it fails to load and read by screen readers.
Syntax:
<img src="file" alt="text">
Example:
<img src="x.png" alt="A sleeping cat">ul
Definition: Unordered (bulleted) list. Items go inside li.
Syntax:
<ul><li>item</li></ul>
Example:
<ul><li>Apples</li><li>Pears</li></ul>ol
Definition: Ordered (numbered) list.
Syntax:
<ol><li>item</li></ol>
Example:
<ol><li>Mix</li><li>Bake</li></ol>table
Definition: Shows data in rows (tr) and cells (td, th).
Syntax:
<table><tr><th>head</th></tr><tr><td>cell</td></tr></table>
Example:
<table border="1"><tr><th>Name</th><th>Age</th></tr><tr><td>Asha</td><td>20</td></tr></table>input
Definition: Form control where the user types or chooses a value.
Syntax:
<input type="text" name="n">
Example:
<input type="text" placeholder="Your name">label
Definition: Caption tied to a form control. Clicking it focuses the field.
Syntax:
<label for="id">Text</label>
Example:
<label for="n">Name</label> <input id="n">required
Definition: Attribute that forces a field to be filled before submit.
Syntax:
<input required>
Example:
<form><input required><button>Send</button></form>h2
Definition: Use h1 for the main title and h2 to h6 for sub-sections.
Syntax:
h2
Example:
<h2>Section</h2>
header
Definition: Tags like header , nav , main , article , section and footer help screen readers and search engines understand your page.
Syntax:
header
Example:
<style>header,footer{background:#14213d;color:#fff;padding:8px}nav a{margin-right:10px}</style>
<header><h2>My Site</h2></header>nav
Definition: Tags like header , nav , main , article , section and footer help screen readers and search engines understand your page.
Syntax:
nav
Example:
<style>header,footer{background:#14213d;color:#fff;padding:8px}nav a{margin-right:10px}</style>
<nav><a href="#">Home</a><a href="#">About</a></nav>main
Definition: Tags like header , nav , main , article , section and footer help screen readers and search engines understand your page.
Syntax:
main
Example:
<main><article><h3>Post title</h3><p>Post text.</p></article></main>
article
Definition: Tags like header , nav , main , article , section and footer help screen readers and search engines understand your page.
Syntax:
article
Example:
<main><article><h3>Post title</h3><p>Post text.</p></article></main>
footer
Definition: Tags like header , nav , main , article , section and footer help screen readers and search engines understand your page.
Syntax:
footer
Example:
<style>header,footer{background:#14213d;color:#fff;padding:8px}nav a{margin-right:10px}</style>
<footer>2026</footer>id
Definition: An id must be unique on a page.
Syntax:
id
Example:
<p id="main" title="Hover me">Unique paragraph</p>
class
Definition: A class can be shared by many elements, and is how you target groups for CSS and JavaScript.
Syntax:
class
Example:
<p class="note">Note one</p> <p class="note">Note two</p>
title
Definition: title shows a tooltip.
Syntax:
title
Example:
<p id="main" title="Hover me">Unique paragraph</p>
audio
Definition: Use audio and video with the controls attribute and a src file.
Syntax:
audio
Example:
<audio controls src="your-sound.mp3"></audio>
video
Definition: Use audio and video with the controls attribute and a src file.
Syntax:
video
Example:
<video controls width="280" src="your-video.mp4"> Your browser does not support video. </video>
controls
Definition: Use audio and video with the controls attribute and a src file.
Syntax:
controls
Example:
<audio controls src="your-sound.mp3"></audio> <video controls width="280" src="your-video.mp4">
src
Definition: Use audio and video with the controls attribute and a src file.
Syntax:
src
Example:
<audio controls src="your-sound.mp3"></audio> <video controls width="280" src="your-video.mp4">
date
Definition: Types like date , number , range and color give people native pickers, and validate on mobile keyboards too.
Syntax:
date
Example:
<p><label>Date <input type="date"></label></p>
number
Definition: Types like date , number , range and color give people native pickers, and validate on mobile keyboards too.
Syntax:
number
Example:
<p><label>Age <input type="number" min="1" max="99"></label></p>
range
Definition: Types like date , number , range and color give people native pickers, and validate on mobile keyboards too.
Syntax:
range
Example:
<p><label>Volume <input type="range"></label></p>
color
Definition: Types like date , number , range and color give people native pickers, and validate on mobile keyboards too.
Syntax:
color
Example:
<p><label>Color <input type="color"></label></p>
lang
Definition: Always declare <!DOCTYPE html> and lang , write lowercase tags, give images alt text, use one h1 , and close every element.
Syntax:
lang
Example:
<html lang="en">
index.html
Definition: Save the file as index.html and open it in a browser.
Syntax:
index.html
Example:
<p>Save as index.html, then open it.</p>'
html
Definition: <!DOCTYPE html> declares HTML5.
Syntax:
html
Example:
<!DOCTYPE html> <html> </html>'
head
Definition: html wraps the page, head holds information about it, and body holds what people see.
Syntax:
head
Example:
<head><title>Skeleton</title></head>
body
Definition: html wraps the page, head holds information about it, and body holds what people see.
Syntax:
body
Example:
<body><p>Visible content</p></body>
br
Definition: Some elements are empty ( br , hr , img ) and have no closing tag.
Syntax:
br
Example:
Line one<br>Line two'
hr
Definition: Some elements are empty ( br , hr , img ) and have no closing tag.
Syntax:
hr
Example:
<hr>
style
Definition: The style attribute takes CSS declarations.
Syntax:
style
Example:
<p style='color:tomato;font-size:24px;background:#eee'>Styled inline</p>'
strong
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
strong
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
em
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
em
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
mark
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
mark
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
small
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
small
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
del
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
del
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
ins
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
ins
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
sub
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
sub
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
sup
Definition: Use strong and em for meaning, and mark , small , del , ins , sub , sup for the rest.
Syntax:
sup
Example:
<p><strong>Important</strong>, <em>stressed</em>, <mark>marked</mark>, <small>small</small>, <del>old</del> <ins>new</ins>, H<sub>2</sub>O, x<sup>2</sup></p>'
blockquote
Definition: blockquote is a long quote, q a short inline one, cite a work title and abbr an abbreviation.
Syntax:
blockquote
Example:
<blockquote cite='https://example.com'>A long quotation sits in its own block.</blockquote>
q
Definition: blockquote is a long quote, q a short inline one, cite a work title and abbr an abbreviation.
Syntax:
q
Example:
<p>She said <q>hello</q> in <cite>My Book</cite>. <abbr title='HyperText Markup Language'>HTML</abbr></p>'
cite
Definition: blockquote is a long quote, q a short inline one, cite a work title and abbr an abbreviation.
Syntax:
cite
Example:
<blockquote cite='https://example.com'>A long quotation sits in its own block.</blockquote> <p>She said <q>hello</q> in <cite>My Book</cite>. <abbr title='HyperText Markup Language'>HTML</abbr></p>'
abbr
Definition: blockquote is a long quote, q a short inline one, cite a work title and abbr an abbreviation.
Syntax:
abbr
Example:
<p>She said <q>hello</q> in <cite>My Book</cite>. <abbr title='HyperText Markup Language'>HTML</abbr></p>'
rgb()
Definition: Set colors with names, #rrggbb , rgb() , hsl() and add transparency with rgba() .
Syntax:
rgb()
Example:
<p style='background:rgb(27,153,139)'>RGB</p>
hsl()
Definition: Set colors with names, #rrggbb , rgb() , hsl() and add transparency with rgba() .
Syntax:
hsl()
Example:
<p style='background:hsl(45,100%,60%)'>HSL</p>
rgba()
Definition: Set colors with names, #rrggbb , rgb() , hsl() and add transparency with rgba() .
Syntax:
rgba()
Example:
<p style='background:rgba(0,0,0,.2)'>RGBA</p>'
link
Definition: Inline (style attribute), internal (a style element in the head) and external (a link to a .css file).
Syntax:
link
Example:
<!-- External: <link rel='stylesheet' href='style.css'> -->'
width
Definition: Use src , alt , width and height .
Syntax:
width
Example:
<img alt='Green square' width='100' height='100' src='data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27100%27 height=%27100%27%3E%3Crect width=%27100%27 height=%27100%27 fill=%27%231b998b%27/%3E%3C/svg%3E'>'
height
Definition: Use src , alt , width and height .
Syntax:
height
Example:
<img alt='Green square' width='100' height='100' src='data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27100%27 height=%27100%27%3E%3Crect width=%27100%27 height=%27100%27 fill=%27%231b998b%27/%3E%3C/svg%3E'>'
tr
Definition: tr is a row, th a header cell and td a data cell.
Syntax:
tr
Example:
<thead><tr><th>Item</th><th colspan='2'>Price</th></tr></thead> <tbody><tr><td>Pen</td><td>2</td><td>USD</td></tr></tbody>
th
Definition: tr is a row, th a header cell and td a data cell.
Syntax:
th
Example:
<style>td,th{border:1px solid #888;padding:6px}table{border-collapse:collapse}</style>
<thead><tr><th>Item</th><th colspan='2'>Price</th></tr></thead>td
Definition: tr is a row, th a header cell and td a data cell.
Syntax:
td
Example:
<style>td,th{border:1px solid #888;padding:6px}table{border-collapse:collapse}</style>
<tbody><tr><td>Pen</td><td>2</td><td>USD</td></tr></tbody>thead
Definition: Use thead , tbody , colspan and rowspan for structure.
Syntax:
thead
Example:
<thead><tr><th>Item</th><th colspan='2'>Price</th></tr></thead>
tbody
Definition: Use thead , tbody , colspan and rowspan for structure.
Syntax:
tbody
Example:
<tbody><tr><td>Pen</td><td>2</td><td>USD</td></tr></tbody>
colspan
Definition: Use thead , tbody , colspan and rowspan for structure.
Syntax:
colspan
Example:
<thead><tr><th>Item</th><th colspan='2'>Price</th></tr></thead>
div
Definition: Block elements ( div , p , h1 ) start a new line and fill the width.
Syntax:
div
Example:
<div style='background:#cde'>Block div</div>
span
Definition: Inline elements ( span , a ) sit within text.
Syntax:
span
Example:
<p>Text with <span style='color:red'>an inline span</span>.</p>'
button
Definition: Use button for actions.
Syntax:
button
Example:
<button type='button' onclick='alert(1)'>Click me</button> <button disabled>Disabled</button>'
type
Definition: Set type to button , submit or reset .
Syntax:
type
Example:
<button type='button' onclick='alert(1)'>Click me</button>
iframe
Definition: An iframe shows another document inside your page.
Syntax:
iframe
Example:
<iframe src='about:blank' title='Empty frame' width='300' height='120' style='border:2px solid #888'></iframe>'
script
Definition: Put code in a script element, or load a file with src .
Syntax:
script
Example:
<script>document.getElementById('x').textContent='After';</script>'meta
Definition: The head can hold title , meta , link , style and script .
Syntax:
meta
Example:
<meta charset='utf-8'> <meta name='viewport' content='width=device-width, initial-scale=1'> <meta name='description' content='Free tutorials'>
code
Definition: code for code, kbd for keyboard input, samp for output, var for variables and pre keeps spacing.
Syntax:
code
Example:
<pre><code>function hi() {
}</code></pre>'kbd
Definition: code for code, kbd for keyboard input, samp for output, var for variables and pre keeps spacing.
Syntax:
kbd
Example:
<p>Press <kbd>Ctrl</kbd>+<kbd>S</kbd>. Output: <samp>Saved</samp>. Set <var>x</var> to 5.</p>
samp
Definition: code for code, kbd for keyboard input, samp for output, var for variables and pre keeps spacing.
Syntax:
samp
Example:
<p>Press <kbd>Ctrl</kbd>+<kbd>S</kbd>. Output: <samp>Saved</samp>. Set <var>x</var> to 5.</p>
var
Definition: code for code, kbd for keyboard input, samp for output, var for variables and pre keeps spacing.
Syntax:
var
Example:
<p>Press <kbd>Ctrl</kbd>+<kbd>S</kbd>. Output: <samp>Saved</samp>. Set <var>x</var> to 5.</p>
pre
Definition: code for code, kbd for keyboard input, samp for output, var for variables and pre keeps spacing.
Syntax:
pre
Example:
<pre><code>function hi() {
}</code></pre>'action
Definition: action is the URL, method is get or post, target chooses where the response opens, autocomplete and novalidate adjust browser help.
Syntax:
action
Example:
<form action='/submit' method='post' autocomplete='off'>
method
Definition: action is the URL, method is get or post, target chooses where the response opens, autocomplete and novalidate adjust browser help.
Syntax:
method
Example:
<form action='/submit' method='post' autocomplete='off'>
autocomplete
Definition: action is the URL, method is get or post, target chooses where the response opens, autocomplete and novalidate adjust browser help.
Syntax:
autocomplete
Example:
<form action='/submit' method='post' autocomplete='off'>
datalist
Definition: Use select , datalist , textarea , fieldset with legend , and output to build full forms.
Syntax:
datalist
Example:
<datalist id='l'><option>HTML</option><option>CSS</option></datalist><br>
textarea
Definition: Use select , datalist , textarea , fieldset with legend , and output to build full forms.
Syntax:
textarea
Example:
<textarea rows='3' cols='24'>Bio</textarea>
fieldset
Definition: Use select , datalist , textarea , fieldset with legend , and output to build full forms.
Syntax:
fieldset
Example:
<fieldset><legend>Profile</legend> </fieldset>'
legend
Definition: Use select , datalist , textarea , fieldset with legend , and output to build full forms.
Syntax:
legend
Example:
<fieldset><legend>Profile</legend>
canvas
Definition: The canvas element is a bitmap you paint with the 2D context: shapes, text and images.
Syntax:
canvas
Example:
<canvas id='c' width='260' height='120' style='border:1px solid #888'></canvas>
VIDEO_ID
Definition: Replace VIDEO_ID with a real ID.
Syntax:
VIDEO_ID
Example:
<iframe width='280' height='160' src='https://www.youtube.com/embed/VIDEO_ID' title='Video' allowfullscreen></iframe>'
draggable
Definition: Set draggable , then handle dragstart , dragover (call preventDefault ) and drop .
Syntax:
draggable
Example:
<div id='d' draggable='true'>Drag me</div><div id='z'>Drop here</div>
preventDefault
Definition: Set draggable , then handle dragstart , dragover (call preventDefault ) and drop .
Syntax:
preventDefault
Example:
z.ondragover=e=>e.preventDefault();
z.ondrop=e=>{e.preventDefault();z.appendChild(d)};popover
Definition: Give an element the popover attribute and point a button at it with popovertarget .
Syntax:
popover
Example:
<button popovertarget='p'>Toggle popover</button> <div id='p' popover style='padding:16px'>Hello from a popover.</div>'
popovertarget
Definition: Give an element the popover attribute and point a button at it with popovertarget .
Syntax:
popovertarget
Example:
<button popovertarget='p'>Toggle popover</button>
localStorage
Definition: localStorage persists, sessionStorage lasts until the tab closes.
Syntax:
localStorage
Example:
try{localStorage.setItem('n','Ada');o.textContent='Saved: '+localStorage.getItem('n')}postMessage
Definition: A worker runs a script in the background and talks to the page with postMessage , so the page stays responsive.
Syntax:
postMessage
Example:
const b=new Blob(['onmessage=e=>{let s=0;for(let i=0;i<=e.data;i++)s+=i;postMessage(s)}']);
w.postMessage(1e7);EventSource
Definition: EventSource keeps a connection open so a server can push messages.
Syntax:
EventSource
Example:
const s=new EventSource('/updates');Example code
<!DOCTYPE html>
<html>
<body>
<h1>My first page</h1>
<p>Hello, web!</p>
</body>
</html>