HTML Cheatsheet
HTML Cheatsheet
HTML Cheatsheet
Online
The Complete
HTML Cheat Sheet
HTML
The Complete HTML Cheat Sheet
Table of Content
Click or tap to jump to any section;
Forms 14 Collective
8 Input Type Attribute Character Objects
Introduction
If you want to be a web developer, it’s crucial to be proficient in HTML – the language
of the internet. A good solution, therefore, is to always have a cheat sheet at hand to
help you in your most troubling moments.
You will find a fairly basic yet comprehensive HyperText Markup Language (HTML)
cheat sheet in this document.
We will go through each major HTML tag and explain how to use them. This document
is also a good starting point for people who want to learn HTML, with
easy-to-understand examples.
Use It Today
Document Summary
Specifies that the webpage is written in Contains the title/name of the webpage. You can
HTML. It appears on the very first and last see this in your web browser’s title bar for every
line of the webpage. It’s mainly used to web page. Search engines use this tag to extract
show that the page uses HTML5 – the the topic of the webpage, which is quite
latest language version. Also known as the convenient when ranking relevant search results.
root element, this tag acts as a parent tag Keep in mind that including this tag in your
for every other tag used on the page. document is mandatory.
Used to specify metadata about the webpage. It Everything the user sees on a webpage is written
includes the webpage’s name, its dependencies inside this tag. It’s a container for all the contents
(JS and CSS scripts), font usage, etc. of the webpage.
Example
<html>
<head>
<title>My First Website</title>
</head>
<body>
</body>
</html>
Document Information
<base> <meta>
Used to specify the base URL of your site. This Metadata tag for the webpage. It can help
tag makes linking to internal links on your site highlight the page’s author, keywords, original
systematized. Remember that this tag can published date, etc.
only be used once and only in the <head> tag.
<link>
Example
<html>
<head>
<meta charset="utf-8">
<base href="http://myfirstwebsite.tld" target="_blank" />
<title>My Beautiful Website</title>
<link rel="stylesheet" href="/css/master.css">
<script type="text/javascript">
var dummy = 0;
</script>
</head>
<body>
</body>
</html>
Document Structure
Six different variations of writing a heading. This tag injects inline elements, like an image,
<h1> has the largest font size, while <h6> icon, or emoticon, without ruining the formatting
has the smallest. or styling of the page.
A single line break for webpages. It’s used A web page’s content is usually divided into
to write a new line. blocks specified by the <div> tag.
Similar to the <br> tag. In addition to switching Plain text is placed inside this tag.
to the next line, <hr> tag also draws a horizontal
bar to indicate the end of the section.
Example
<div>
<h1>Top 10 Greatest Films</h1>
<p>These are considered the greatest movies of all time.</p>
<hr>
<h2>The Godfather</h2>
<p>This 1972 classic stars Marlon Brando and Al Pacino.</p>
</div>
Text Formatting
Another emphasis tag, but displays Used to display text in italics but does not
text in italics. emphasize it like the <em> tag.
A tag for citing the author of a quote. Denotes text that has been added to the webpage.
Quotes often go into this tag. Is used Pre-formatted, monospaced font text laid out, with
in tandem with the <cite> tag. whitespace inside the element, remained intact.
Similar to the above tag, but for shorter quotes. A tag for specifying the author’s contact details.
Used to display code snippets within Used to write a subscript. It’s smaller font just
a paragraph. below the mid-point of regular fonts. Example: ax.
Similar to the <sub> tag, but used to Reduces text size. In HTML5, it often refers
write a superscript. Example: ax. to redundant or invalid information.
Example
<blockquote>
Anyone who has never made a mistake has never tried anything new.
<cite>- Albert Einstein</cite>
your web content should be easy to perceive for any visitor.
</blockquote>
<pre>
Here's what pre-formatted text looks like.
</pre>
Links
A tag dedicated to sending emails. An anchor tag. Primarily used to include hyperlinks.
A variation of the <a name="name"> tag. An anchor tag for mentioning contact numbers.
Used to navigate to the web page's <div> The numbers are clickable, which can be
section only. particularly beneficial for mobile users.
Images
<img> <area>
alt="text" coords=""
A text is displayed when the user hovers Coordinates vital information about the
the mouse over an image. It can be used to shape. Example: vertices for rectangles,
give additional details about the image. center or radius for circles.
border="" src="url"
Specifies the border thickness of the image. A URL or path where the image is located
If not mentioned, the default value is 0. on your drive or the web.
width="" height=""
Specifies image width in pixels or percentages. Specifies image height in pixels or percentages.
Name of the map associated between The relative alignment of an image. It can change
an image and a map. parallel to other elements on a web page.
Example
<img src="https://upload.wikimedia.org/wikipedia/commons/8/83/Solar_system.jpg"
width="823" height="1024" alt="The Solar System"
usemap="#solarmap">
<map name="solarmap">
</map>
Lists
A tag for an ordered or numbered list of items. An individual item as part of a list.
Opposed to the <ul> tag. Used for an A definition of a single term that is in-line
unordered list of items. with body content.
A tag for a list of items with definitions. A description of the defined term.
Example
Forms
A parent tag for an HTML form. Where the form data will be submitted once the user fills it.
method="" enctype=""
Specifies which HTTP method (POST or Used only for the POST method. It dictates the
GET) will be used to submit the form. data encoding scheme when a form is submitted.
autocomplete novalidate
Identifies groups of all fields on the form. Operates as a caption for the <fieldset> element.
type="" size=""
Determines which type of input (text, dates, Determines the input element width
password) is requested from the user. (number of characters).
name="" maxlength=""
Specifies the name of the input field. Specifies the most input field characters allowed.
value="" required
Specifies the value currently contained Makes an input field compulsory. The form cannot
in the input field. be submitted if a required field is left empty.
width="" height=""
Determines the width of the input element Determines the height of the input element in
in pixel values. pixel values.
placeholder="" pattern=""
This tag can be used to provide a hint to the Specifies a regular expression that can be
user about the nature of the requested data. used to look for patterns in the user’s text.
min="" max=""
The minimum value allowed for an The maximum value allowed for an
<input> element. <input> element.
autofocus disabled
Forces focus on the input element when a Disables an input element. The user can no
web page loads completely. longer enter data.
Applied for longer strings of input. It can be used Specifies a list of options that the user
to get a multi-sentence text from the user. can choose from.
Select Attributes
name="" size=""
A name for a particular list of options. A total number of options given to the user.
multiple required
States if the user can choose multiple Specifies if choosing an option(s) is necessary
options from the list. for form submission.
Specifies that a drop-down list will automatically A tag for listing individual items on the list of
come into focus after the page loads. options.
Option Attributes
value="" selected
A text visible to the user for any given option. Determines which option is selected by
default when a form loads.
<button> … </button>
Example
Tables
Determines the footer of a table. The body of a table where the data is held.
Denotes a single row in a table. Specifies information about specific columns of a table.
The value of a heading of a table’s column. A single cell of a table. Contains the actual value/data.
Example
<table>
<colgroup>
<col span="2">
<col>
</colgroup>
<tr>
<th>Name</th>
<th>Major</th>
<th>GPA</th>
</tr>
<tr>
<td>Bob</td>
<td>Law</td>
<td>3.55</td>
</tr>
<tr>
<td>Alice</td>
<td>Medicine</td>
<td>3.61</td>
</tr>
</table>
Used to embed an additional multimedia An inline block of content. It’s used as a container for
object into a web page. This can be an multimedia objects in a flexible manner. It floats inside a web
audio/video file, document (.pdf), etc. page, meaning it’s placed relative to other webpage items.
height="" width=""
Determines object height in pixel values. Determines object width in pixel values.
type=""
iFrame Attributes
name="" srcdoc=""
The source URL/path of the multimedia Used for iFrame customization. This includes
object to be held inside an iFrame. additional parameters to go along with the content.
height="" width=""
<embed> … </embed>
Embed Attributes
height="" width=""
Determines the height of an embedded item. Determines the width of an embedded item.
src="" type=""
Example
Specifies the webpage header. It can also Specifies the webpage footer. It can also be
be used for objects inside the web page. used for objects inside the web page.
A tag reserved for figures (diagrams, Used as a heading for the <details> tag.
charts) in HTML5. It’s always visible to the user.
A description of the figure is placed inside. Used to highlight a particular portion of a text.
Navigation links for the user in a web page. A particular item from a list or menu.
Measures data within a given range. Typically used as a progress bar. This is used
to track progress.
Shows text for web browsers without Describes a Ruby annotation for East
Ruby annotation support. Asian typography.
Displays East Asian typography character details. A tag for formatting date and time.
<wbr>
Quotation Marks (“) Ampersand (&) Less than sign (<) Greater than sign (>)
Non-breaking space ( ) Copyright symbol (©) @ Symbol (@) Small bullet (•)
™ û