Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/learn/html/cheatsheet/index.md
6546 views
---
title: HTML Cheat Sheet slug: Learn/HTML/Cheatsheet
---

{{LearnSidebar}}

While using {{Glossary("HTML")}} it can be very handy to have an easy way to remember how to use HTML tags properly and how to apply them. MDN provides you with an extended HTML documentation as well as a deep instructional HTML how-to. However, in many cases we just need some quick hints as we go. That's the whole purpose of the cheat sheet, to give you some quick accurate ready to use code snippets for common usages.

Note: HTML tags must be used for their semantic, not their appearance. It's always possible to totally change the look and feel of a given tag using {{Glossary("CSS")}} so, when using HTML, take the time to focus on the meaning rather than the appearance.

Inline elements

An "element" is a single part of a webpage. Some elements are large and hold smaller elements like containers. Some elements are small and are "nested" inside larger ones. By default, "inline elements" appear next to one another in a webpage. They take up only as much width as they need in a page and fit together horizontally like words in a sentence or books shelved side-by-side in a row. All inline elements can be placed within the <body> element.

Usage Element Example
A link {{HTMLElement("a")}}

<a href="https://example.org">
A link to example.org</a>.
{{EmbedLiveSample("a-example", 100, 60)}}
An image {{HTMLElement("img")}}
<img src="beast.png" width="50" />
{{EmbedLiveSample("img-example", 100, 60)}}
An inline container {{HTMLElement("span")}}

Used to group elements: for example,
to <span style="color:blue">style
them</span>.
{{EmbedLiveSample("span-example", 100, 60)}}
Emphasize text {{HTMLElement("em")}}
<em>I'm posh</em>.
{{EmbedLiveSample("em-example", 100, 60)}}
Italic text {{HTMLElement("i")}}

Mark a phrase in <i>italics</i>.
{{EmbedLiveSample("i-example", 100, 60)}}
Bold text {{HTMLElement("b")}}
Bold <b>a word or phrase</b>.
{{EmbedLiveSample("b-example", 100, 60)}}
Important text {{HTMLElement("strong")}}
<strong>I'm important!</strong>
{{EmbedLiveSample("strong-example", 100, 60)}}
Highlight text {{HTMLElement("mark")}}
<mark>Notice me!</mark>
{{EmbedLiveSample("mark-example", 100, 60)}}
Strikethrough text {{HTMLElement("s")}}
<s>I'm irrelevant.</s>
{{EmbedLiveSample("s-example", 100, 60)}}
Subscript {{HTMLElement("sub")}}
H<sub>2</sub>O
{{EmbedLiveSample("sub-example", 100, 60)}}
Small text {{HTMLElement("small")}}

Used to represent the <small>small
print </small>of a document.
{{EmbedLiveSample("small-example", 100, 60)}}
Address {{HTMLElement("address")}}

<address>Main street 67</address>
{{EmbedLiveSample("address-example", 100, 60)}}
Textual citation {{HTMLElement("cite")}}

For more monsters,
see <cite>The Monster Book of Monsters</cite>.
{{EmbedLiveSample("cite-example", 100, 60)}}
Superscript {{HTMLElement("sup")}}
x<sup>2</sup>
{{EmbedLiveSample("sup-example", 100, 60)}}
Inline quotation {{HTMLElement("q")}}
<q>Me?</q>, she said.
{{EmbedLiveSample("q-example", 100, 60)}}
A line break {{HTMLElement("br")}}
Line 1<br>Line 2
{{EmbedLiveSample("br-example", 100, 80)}}
A possible line break {{HTMLElement("wbr")}}

<div style="width: 200px">
  Llanfair<wbr>pwllgwyngyllgogerychwyrngogogoch.
</div>
{{EmbedLiveSample("wbr-example", 100, 80)}}
Date {{HTMLElement("time")}}

Used to format the date. For example:
<time datetime="2020-05-24" pubdate>
published on 23-05-2020</time>.
{{EmbedLiveSample("time-example", 100, 60)}}
Code format {{HTMLElement("code")}}

This text is in normal format,
but <code>this text is in code
format</code>.
{{EmbedLiveSample("code-example", 100, 60)}}
Audio {{HTMLElement("audio")}}

<audio controls>
  <source src="https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3" type="audio/mpeg">
</audio>
        
{{EmbedLiveSample("audio-example", 100, 80)}}
Video {{HTMLElement("video")}}

<video controls width="250"
  src="https://archive.org/download/ElephantsDream/ed_hd.ogv" >
  <a href="https://archive.org/download/ElephantsDream/ed_hd.ogv">Download OGV video</a>
</video>
{{EmbedLiveSample("video-example", 100, 200)}}

Block elements

"Block elements," on the other hand, take up the entire width of a webpage. They also take up a full line of a webpage; they do not fit together side-by-side. Instead, they stack like paragraphs in an essay or toy blocks in a tower.

Note: Because this cheat sheet is limited to a few elements representing specific structures or having special semantics, the div element is intentionally not included — because the div element doesn't represent anything and doesn't have any special semantics.

Usage Element Example
A simple paragraph {{HTMLElement("p")}}

<p>I'm a paragraph</p>
<p>I'm another paragraph</p>
{{EmbedLiveSample("p-example", 100, 150)}}
An extended quotation {{HTMLElement("blockquote")}}

They said:
<blockquote>The blockquote element indicates
an extended quotation.</blockquote>
{{EmbedLiveSample("blockquote-example", 100, 100)}}
Additional information {{HTMLElement("details")}}

<details>
  <summary>Html Cheat Sheet</summary>
  <p>Inline elements</p>
  <p>Block elements</p>
</details>
{{EmbedLiveSample("details-example", 100, 150)}}
An unordered list {{HTMLElement("ul")}}
<ul>
<li>I'm an item</li>
<li>I'm another item</li>
</ul>
{{EmbedLiveSample("ul-example", 100, 100)}}
An ordered list {{HTMLElement("ol")}}
<ol>
<li>I'm the first item</li>
<li>I'm the second item</li>
</ol>
{{EmbedLiveSample("ol-example", 100, 100)}}
A definition list {{HTMLElement("dl")}}
<dl>
  <dt>A Term</dt>
<dd>Definition of a term</dd> <dt>Another Term</dt> <dd>Definition of another term</dd> </dl>
{{EmbedLiveSample("dl-example", 100, 150)}}
A horizontal rule {{HTMLElement("hr")}}
before<hr>after
{{EmbedLiveSample("hr-example", 100, 100)}}
Text Heading {{HTMLElement("Heading_Elements", "<h1>-<h6>")}}

<h1> This is Heading 1 </h1>
<h2> This is Heading 2 </h2>
<h3> This is Heading 3 </h3>
<h4> This is Heading 4 </h4>
<h5> This is Heading 5 </h5>
<h6> This is Heading 6 </h6>
{{EmbedLiveSample("h1-h6-example", 100, 350)}}