You are on page 1of 9

HTML Cheat Sheet

HTML Page Structure


pagename.html Purpose Attributes
<?xml version="1.0" encoding="UTF-8"?> xml declaration, recommended version, encoding
<?xml-stylesheet type="text/xsl" href="/template.xsl"?> stylesheet processing instruction, optional type, href
<!DOCTYPE html> document type declaration, recommended PUBLIC, SYSTEM
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <html> top element tag, required xmlns manifest version
common
<head> head section, required profile common
<title>...</title> title tag, required common attributes
...other head section tags... HTML Head Section Tags
</head> End of <head> section
<body> <body> tag, required alink background bgcolor link
...body tags... HTML Body Tags onafterprint onbeforeprint
onhashchange onmessage
onoffline ononline onpopstate
onredo onstorage onundo text
vlink common
</body> End of body of HTML document
</html> End of HTML document

This is an automatically-generated printer-friendly PDF version of the HTML web page at HTML Cheat Sheet ← CLICK HERE to get the
standard HTML version of this document.
HTML Character Entities <body> Tags
Character Named Entity Decimal Hexadecimal HTML Tag Purpose Attributes
" - double quotes &quot; &#34; &#x22; <a href="..." ...> hypertext link href accesskey charset
& - ampersand &amp; &#38; &#x26; coords hreflang media ping
rel rev shape target type
' - apostrophe / single quote &apos; &#39; &#x27;
<a id="..."/> ../definitions/placeholderid name
< - less than sign &lt; &#60; &#x3c; link (anchor)
> - greater than sign &gt; &#62; &#x3e; <abbr> acronym or clear common
non-breaking space &nbsp; &#160; &#xa0; abbreviation
¢ - cents sign &cent; &#162; &#xa2; <acronym> acronyms,
© - copyright symbol &copy; &#169; &#xa9; deprecated

® - registered trademark &reg; &#174; &#xae; <address> contact information common


for ancestor <article>
• - bullet &bull; &bullet; &#8226; &#x2022; or <body>
™ - trademark &trade; &#8482; &#x2122; <applet> Java applets,
deprecated

Page 1 of 9 1
HTML Cheat Sheet
Miscellaneous HTML Tag Purpose Attributes
HTML Tag Purpose Usage <area/> area inside image accesskey alt coords href
<!--...--> comments must not contain "--" maps hreflang media nohref ping
rel shape target type
Tag and Attribute Coding common
Definition: Polyglot HTML Documents: HTML documents that can be parsed as either <article> New sectioning tag pubdate common
text/html or as an XML type such as application/xhtml+xml. for main article
Tags <aside> New sectioning tag common
Properly Nested Tags for sidebar
<p>...</p> <p>... <P>...</P> <audio> New embedded audio autobuffer autoplay controls
<tr><td>...</td></tr> <tr><td>...</tr></td> content loop src common
Empty Tags <b> bold keywords or common
<br/> <br> other text with no
<hr/> <hr> extra importance
<img src="example.png" alt="example"/> <bb> New type common
<img src="example.png" alt="example">
<bdo> bi-directional text dir common
Attributes override
Quoted Attributes <bgsound> background sound,
<abbr title="Hypertext Markup Language">HTML</abbr> deprecated
<a href=http://www.ExampleOnly.com/> <!-- ambiguous -->
<big> larger text,
<a href="http://www.ExampleOnly.com/"> <!-- / is part of URL -->
deprecated
<p id=back-to-top>
<p id="back-to-top"> <blockquote> block of quoted text cite common
Style Attributes <br/> line break common
<table width="100%"> <button> standalone accesskey autofocus
<table style="width: 100%"> pushbutton disabled form formaction
<table class="wide"> formenctype formmethod
formnovalidate formtarget
Boolean Attributes
name type value common
<option selected="selected"/>
<option selected/> <canvas> New height width common
<option selected=""/> <caption> table caption align common
<option selected="true"/>
<option selected="yes"/> <center> centered blocks,
deprecated
Definitions of Acronyms and Abbreviations <cite> citation common
Defined Term, not definition, in title attribute
A <dfn title="short for weblog">blog</dfn> is an online journal. <code> program code common
A <dfn title="blog">blog or weblog</dfn> is an online journal. <col/> table column align char charoff span valign
A <dfn>blog</dfn>, short for <dfn>weblog</dfn>, is an online journal. width common
<dfn> gets default title from an <abbr> tag that is its only content <colgroup> group of table align char charoff span valign
<dfn><abbr title="National Association for Stock Car Auto columns width common

2 Page 2 of 9
HTML Cheat Sheet
Racing">NASCAR</abbr></dfn> sanctions many different motor races HTML Tag Purpose Attributes
Override default title on <dfn> when expanding acronyms <command/> New accesskey checked default
<dfn title="TLA"><abbr title="Three Letter Acronym">TLA</abbr></dfn> stands for "Three disabled hidden icon label
Letter Acronym" radiogroup type common
or, look up acronym in the Acronym Finder at Acronyms .net and just <datagrid> New disabled common
copy-and-paste the code <datalist> New common
<dd> definition description common
Namespaces
<del> deleted text cite datetime common
Namespace URI Purpose
<details> New open common
xmlns="http://www.w3.org/1999/xhtml" HTML
xmlns:html="http://www.w3.org/1999/xhtml" <dialog> New common
xmlns:mathml="http://www.w3.org/1998/Math/MathML" MathML <dir> directory listing,
deprecated
xmlns:svg="http://www.w3.org/2000/svg" SVG
<div> division align common
xmlns:xml="http://www.w3.org/XML/1998/namespace" XML
<dfn> inline defined term title="defined term"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" XML instance
title="definition" common
document
<dl> definition list compact common
<head> Section Tags <dt> term defined in list common
HTML Tag Purpose Attributes <em> emphasized text common
<base/> base URL for other URLs href target <embed/> New height src type width
in the document common
<basefont> base font, deprecated <fieldset> disabled form name common
<isindex> input field to submit <figure> New common
keyword-based query, <fn> footnotes,
deprecated deprecated
<link/> reference to external href rel charset hreflang media rev <font> font, deprecated
resource sizes target title type common
<footer> New footer section common
<meta http-equiv="..."/> HTTP header equivalent http-equiv content charset
<form> form accept accept-charset action
<meta name="..."/> document metadata name content charset scheme data enctype method replace
common target common
<script> dynamic HTML script async charset defer language src <frame> frames, deprecated
type
<frameset> top level element for
<style> style definitions media type scoped title a web page with
<title> page title common frames, deprecated
<h1> <h2> <h3> heading levels 1-6 align common
HTML Metatags <h4> <h5> <h6>
HTML Metatag Purpose Content <header> New header section
http-equiv="Cache-Control" cache control
Page 3 of 9 3
HTML Cheat Sheet
HTML Metatag Purpose Content HTML Tag Purpose Attributes
http-equiv="Content-Disposition" embedded content or <hgroup> New group of common
attachment headings for section
http-equiv="Content-Language" equivalent to HTTP <hr/> horizontal rule for a align noshade size width
Content-Language thematic break common
header, deprecated <i> italics for technical common
http-equiv="Content-Type" content media type terms, phrases in
http-equiv="Default-Style" other languages, etc.
http-equiv="Expires" cache expiration date <iframe> inline frame align frameborder height
longdesc marginheight
http-equiv="Refresh" refresh or redirect marginwidth name sandbox
http-equiv="X-UA-Compatible" user agent compatibility seamless scrolling src width
name="author" author common

name="classification" <img/> image align alt border height


hspace ismap longdesc
name="copyright" copyright notice name src usemap vspace
name="description" description width common
name="formatter" <input/> input field or control accept accesskey align alt
autocomplete autofocus
name="generator"
checked disabled form
name="google" Google archive directive formaction formenctype
name="googlebot" Google robot directive formmethod formnovalidate
formtarget height list max
name="HandheldFriendly" for pages designed for content="true" maxlength min multiple name
handheld devices pattern placeholder readonly
name="keywords" keywords required size src step type
name="rating" rating value width common
name="robots" robots directive <ins> inserted text cite datetime common
name="verify" <kbd> keyboard input common
name="viewport" viewport size for <label> label for form control for common
small-screen / handheld <legend> accesskey align common
devices <li> list item type value (<ol> only)
common
Common Attributes
<mark> New mark selected common
Attribute Purpose Example text
accesskey="..." single case-insensitive <map> image map name common
character to change
focus, deprecated <menu> menu list compact label type common
class="..." space-separated list of class="todo high" matches .todo <meter> New meter or gauge high low max min optimum
class names for CSS or and .high selectors in CSS value common
dynamic selection <nav> New navigation common
4 Page 4 of 9
HTML Cheat Sheet
Attribute Purpose Example HTML Tag Purpose Attributes
contenteditable="..." New section
contextmenu="..." New <noembed> Alternate content to No replacement needed
data-*="..." New author-defined be displayed when since the embed tag has
attributes the <embed/> tag is been standardized in HTML
not supported, 5
dir="..." deprecated
draggable="..." New <noframes> Alternate content to No replacement needed
id="..." be displayed when since frames have been
hidden="..." New frames are not removed from the HTML 5
supported, standard
lang="..." ISO 639-1 language lang="en" lang="en-US" deprecated
code, ISO 3166-1
country code, variant <noscript> fallback content when common
scripting is disabled
spellcheck="..." New
<object> embedded object align archive border classid
style="..." inline styles separated by codebase codetype data
semicolons declare height hspace object
tabindex="..." standby type usemap vspace
width common
title="..." title
<ol> ordered list compact reversed start type
onabort="..." abort event
common
onbeforeonload="..." before onload event
<optgroup> option group disabled label common
onbeforeunload="..." before unload event
<option> option in selection list disabled label selected value
onblur="..." lost focus event common
onchange="..." content changed event <output> New form common
onclick="..." mouse clicked event <p> paragraph align common
oncontextmenu="..." context menu event <param/> parameter for object name type value valuetype
oncopy="..." copy event common
oncut="..." cut event <pre> preformatted text width common
ondblclick="..." mouse double-clicked <progress> New progress bar max value common
event <q> quotation cite common
ondrag="..." drag event <rp> New parenthesized common
ondragend="..." drag ended event ruby text
ondragenter="..." drag entered event <rt> New ruby text common
ondragleave="..." drag exited event <ruby> New ruby annotation common
ondragover="..." drag over event <s> strike-through text,
deprecated
ondragstart="..." drag start event
<samp> sample program code common
ondrop="..." drop event

Page 5 of 9 5
HTML Cheat Sheet
Attribute Purpose Example HTML Tag Purpose Attributes
onerror="..." error event <section> New section cite common
onfocus="..." gained focus event <select> selection list autofocus data disabled form
ongesturechange="..." gesture change event multiple name common
ongestureend="..." end of gesture event <small> smaller text for common
comments and
ongesturestart="..." start of gesture event legalese
onkeydown="..." key pressed down event <source/> New external media media src type common
onkeypress="..." key pressed event source
onkeyup="..." key released event <span> inline group common
onload="..." document loaded event <strike> strike-through text,
onmousedown="..." mouse button pressed deprecated
down event <strong> text with greater common
onmousemove="..." mouse moved event importance

onmouseout="..." mouse cursor exited <sub> subscript common


event <sup> superscript common
onmouseover="..." mouse cursor entered <table> table layout align bgcolor border
event cellpadding cellspacing
onmouseup="..." mouse button released frame rules summary width
event common

onmousewheel="..." mouse wheel rotated <tbody> table body align char charoff valign
event common

onmove="..." move event <td> table cell abbr align axis bgcolor char
charoff colspan headers
onorientationchange="..." device orientation height nowrap rowspan
changed event scope valign width common
onpaste="..." paste event <textarea> text input area accesskey autofocus cols
onreset="..." form reset event disabled form maxlength
name placeholder readonly
onresize="..." resize event
required rows wrap common
onscroll="..." scroll event
<tfoot> table footer align char charoff valign
onselect="..." select event common
onsubmit="..." form submit event <th> table column heading abbr align axis bgcolor char
ontouchcancel="..." touch cancelled event charoff height nowrap valign
width common
ontouchend="..." touch ended event
<thead> table heading align char charoff valign
ontouchmove="..." touch move event common
onstouchstart="..." touch started event <time> New time and/or date datetime common
onunload="..." document unloaded <tr> table row align bgcolor char charoff

6 Page 6 of 9
HTML Cheat Sheet
Attribute Purpose Example HTML Tag Purpose Attributes
event valign common
<tt> teletype text,
HTML Media Types and Expressions deprecated
Media Type Description <u> underlined text,
all for all device types, default deprecated
aural for speech synthesizers <ul> unordered list compact type common
braille for braille printers <var> variable common
handheld for handheld devices such as cell phones, <video> New embedded video autobuffer autoplay controls
PDAs and other mobile Internet devices height loop poster src width
common
print for printers
<xmp> example code using
projection for projection displays preformatted text,
screen for traditional computer-based web browsers deprecated
tty for teletypes and other media with
fixed-width-character output
tv for televisions and similar devices with limited
input capability
screen,handheld comma-separated "or"-ed list
handheld and (min-width:200px) expressions with media queries

.htaccess
Directive Purpose
DirectoryIndex /index.html default page
ErrorDocument 404 /error.html error page
AddType application/xhtml+xml;charset=utf-8 html HTML 5 media type

This is an automatically-generated printer-friendly PDF version of the HTML web pages at HTML Cheat Sheet ← CLICK HERE to get the
standard HTML version of this document.

Page 7 of 9 7
Index
<a> anchor tag... 1 cents sign... 1 <frameset> tag... 3 media types... 7
abbreviations... 2 character encoding... 1 <frame> tag... 3 <menu> tag... 4
<abbr> tag... 1 <cite> tag... 2 gauge... 4 <meta> tag... 3
acronyms... 2 <code> tag... 2 global attributes... 4 metatags... 3
<acronym> tag... 1 <colgroup> tag... 2 handheld media type... 7 <meter> tag... 4
<address> tag... 1 <col> tag... 2 <header> tag... 3 namespaces... 3
<a> link tag... 1 column headings... 6 heading tags... 3 <nav> tag... 4
ampersand... 1 <command> tag... 3 <head> section... 1 nested tags... 2
<a> placeholder link... 1 comments... 2 <head> section tags... 3 <noembed> tag... 5
apostrophe... 1 common attributes... 4 <head> tag... 1 <noframes> tag... 5
<applet> tag... 1 context menu event... 5 <hgroup> tag... 4 non-breaking space... 1
<area> tag... 2 copyright symbol... 1 horizontal rule... 4 <noscript> tag... 5
<article> tag... 2 <datagrid> tag... 3 <hr> tag... 4 <object> tag... 5
<aside> tag... 2 <datalist> tag... 3 .htaccess file... 7 <ol> tag... 5
attribute coding... 2 date tag... 6 HTML attribute coding... 2 <optgroup> tag... 5
<audio> tag... 2 <dd> tag... 3 <html> tag... 1 <option> tag... 5
aural media type... 7 definition description... 3 HTML tag coding... 2 <output> tag... 5
author-defined attributes... 5 definition list... 3 HTML version attribute... 1 page title... 3
background sound... 2 definitions... 2 http-equiv metatag... 3 <param> tag... 5
<basefont> tag... 3 <del> tag... 3 <iframe> tag... 4 preformatted text... 7
<base> tag... 3 <details> tag... 3 image map... 4 <pre> tag... 5
<bb> tag... 2 <dfn> tag... 3 <img> tag... 4 print media type... 7
<bdo> tag... 2 <dialog> tag... 3 <input> tag... 4 <progress> tag... 5
<bgsound> tag... 2 <dir> tag... 3 <ins> tag... 4 projection media type... 7
<big> tag... 2 <div> tag... 3 <isindex> tag... 3 <p> tag... 5
<blockquote> tag... 2 <dl> tag... 3 <i> tag... 4 <q> tag... 5
<body> tag... 1 document type... 1 italicized text... 4 quotation... 5
body tags... 1 <dt> tag... 3 <kdb> tag... 4 quotes... 1
bold text... 2 <embed> tag... 3 <label> tag... 4 registered trademark... 1
boolean attributes... 2 empty tags... 2 <legend> tag... 4 <rp> tag... 5
braille media type... 7 <em> tag... 3 line break... 2 <rt> tag... 5
<br> tag... 2 event attributes... 5 <link> tag... 3 ruby annotation... 5
<b> tag... 2 <fieldset> tag... 3 list item... 4 ruby parenthesized text... 5
bullet... 1 <figure> tag... 3 <li> tag... 4 <ruby> tag... 5
<button> tag... 2 <fn> tag... 3 manifest attribute... 1 ruby text... 5
<canvas> tag... 2 <font> tag... 3 <map> tag... 4 <samp> tag... 5
<caption> tag... 2 <footer> tag... 3 <mark> tag... 4 screen media type... 7
<center> tag... 2 <form> tag... 3 media queries... 7 <script> tag... 3

8 Page 8 of 9
Index
<section> tag... 6 underlined text... 7
selection list... 6 unordered list... 7
<select> tag... 6 <u> tag... 7
<small> tag... 6 <var> tag... 7
<source> tag... 6 <video> tag... 7
<span> tag... 6 void tags... 2
<s> tag... 5 xml declaration... 1
<strike> tag... 6 xmlns attribute... 1
<strong> tag... 6 XML version attribute... 1
style attributes... 2 <xmp> tag... 7
style attributes... 2
style sheets... 1
<style> tag... 3
<sub> tag... 6
<sup> tag... 6
table body... 6
table caption... 2
table cell... 6
table footer... 6
table heading... 6
<table> tag... 6
<tbody> tag... 6
<td> tag... 6
teletype text... 7
<textarea> tag... 6
text input area... 6
<tfoot> tag... 6
<thead> tag... 6
<th> tag... 6
<time> tag... 6
<title> tag... 1
<title> tag... 3
trademark... 1
<tr> tag... 6
<tt> tag... 7
tty media type... 7
tv media type... 7
<ul> tag... 7

Page 9 of 9 9

You might also like