HTML and HTML5 Cheat Sheets
HTML and HTML5 Cheat Sheets
sheets
HTML and HTML5 Cheat sheets for tags of Text
formatting, Section Division, Images, Links, Lists,
Frames, Forms, Special Characters and much more
Developed by SnippetNuggets.com
1 | HTML and HTML5 Cheat Sheet by www.SnippetNuggets.com
<title> … </title>
This tag contains name/title of the page. It is the
Document Information Tags
name visible at the title’s bar or tab bar of browser.
<base> … </base>
Nuggets:
This tag is used to specify base URL/target of
• Search Engines use title as one of the most webpage for all relative URLs of a webpage. It also acts
important parameter for indexing webpage.
Hence, a relevant and informative title helps
improving ranking of your webpage.
2 | HTML and HTML5 Cheat Sheet by www.SnippetNuggets.com
<head>
<script>
<link> … </link> document.getElementById("demo").innerHTML = "Hello
JavaScript!";
This tag is used to link resources like CSS and fonts
</script>
which are external to the webpage. </head>
Nuggets:
• Using <base> tag will make website design easy <noscript> … </noscript>
to maintain and lesser prone to link mismatch. This tag is used to provide an alternate message or
content for users if the browser doesn’t support client-
side JavaScripts.
3 | HTML and HTML5 Cheat Sheet by www.SnippetNuggets.com
<p> … </p>
<h1..h6> … </h1..h6> This tag is used to display plain text as it is.
Nuggets:
HTML supports six levels of headings from
h1(largest) to h6 (smallest). One can further customize • Browsers automatically put some space/margin
their size/color/font through CSS. before and after each <p> element. This
Nuggets: behavior of browser can be modified using CSS
margin-left/right.
• Heading is given importance during indexing of
webpage by Search Engines. Also, headings are <br/>
used to categorize webpage in a better way so This tag inserts a single line break wherever placed.
It is an empty tag with no closing tag. In HTML/HTML5
<div class="myClass"> <br> is sufficient but in XHTML, properly closed <br/> is
<h1>Largest heading</h1> expected. <br/> tag doesn’t display a line, instead use
<h6>Smallest heading</h6> <hr/> tag
<p>This is paragraph displaying fruits color:
<span style="color: red">red apple</span> and <span
style="color: yellow;"> yellow mango </span> <hr/>
</p> This tag displays a single line break wherever placed.
</hr> It is an empty tag with no closing tag.
</br>
</div>
Example
that User find it easy to browse through
<p>
document structure. Hence, Heading should be
Text with different color:
given due importance.
<span style=”color: red”> red apple </span> and <span
style=”color: yellow;”> yellow mango </span>
<div> … </div> </p>
This tag divides webpage into different blocks or
sections by enclosing element(s) inside <div> which has
to be shown as one block.
Nuggets:
4 | HTML and HTML5 Cheat Sheet by www.SnippetNuggets.com
<abbr title=”United States of America”> USA </abbr> consists Used for navigate to DOM element having class
of 50 states. name ‘class_name’ when anchor link is clicked.
<blockquote
cite=”https://en.wikipedia.org/wiki/United_States”> USA consists of
50 states and consists of North America and Alaska </blockquote>
Image Tag
<p><dfn>USA</dfn> consists of 50 state</p> <img> … <img/>
Used to insert and display image in webpage with
desired height, width, position. List of attributes:
<ul>
<ul> … </ul> <li>Coffee</li>
Defines an unordered or bulleted/dotted list. <li>Tea</li>
Following attributes are used in <ul> element: <li>Milk</li>
</ul>
1. type=’disc|square|circle’
<dl>
Specifies the kind of marker to use in the list. It
<dt>Coffee</dt>
is not supported in HTML5. Hence, same result <dd>Black hot drink</dd>
is achieved using CSS property ‘list-style-type’ <dt>Milk</dt>
with value: ‘disc|square|circle’ <dd>White cold drink</dd>
</dl>
<ol> … </ol>
in conjunction with <dl> (defines a description list) and
Defines an ordered list. Following attributes are used
<dd> (describes each term/name).
in <ol> element:
1. reversed:
Form Tag
Specifies that list ordering should be in reverse
order of number like(5,4,3,2,1 or e, d, c, b, a).
Example: <ol reversed> … </ol>
<form> … </form>
2. start=’<number>’
Used for creating HTML form for user to input. Form
Specifies start value of numbering.
elements contain several elements(like input box,
3. type=’1|A|a|I|i’
textarea, button, select menu etc) to let user input the
Specifies the kind of marker used in ordered list
data. All such elements for user inputs are enclosed
like numeral, Uppercase alphabetic, Lowercase
inside <form> element.
alphabetic, Uppercase roman and Lowercase
roman Following attributes can be used in <form> element:
2. action=”URL”
URL where the form data will be submitted
Input Tag
after user fills form and submit. Used to create input elements inside the form.
3. autocomplete=”on|off” Based on the value of ‘type’ attribute, Input element
Specifies whether a form should have changes behavior to button, checkbox, color, data,
autocomplete on or off. datetime-local, file, email, radio, range etc. Given
4. enctype=” application|x-www-form- below are different attributes of <input> element.
urlencoded|multipart|form-data|text|plain”
Specifies how form-data should be encoded 1. accept=”file_extension|audio/*|video/*|image
when submitting it to the server(only for /*|media_type”
method=”post”) Specifies the types of files that server
5. name=”text” accepts(only for type=”file”)
Specifies the name of a form 2. alt=”text”
6. method=”get|post” Specifies an alternate text for images(only when
Specifies HTTP method to use while sending type=”image” is used in <input>). ‘alt’ attribute
form-data over network. is important for Indexing by Search Engines.
7. novalidate 3. autocomplete=”on|off”
Specifies that form should not be validated Specifies, if <input> should have autocomplete
while submitting. enabled or disabled.
8. target=”_blank|_self|_parent|_top” 4. autofocus
Specifies where to display the response which is Specifies if <input> element should get
received after submitting the form. autofocus when page loads.
5. checked
Other child elements of <Form> Specifies the state of <input> element
type=”checkbox” or type=”radio”
<fieldset> … </fieldset> 6. disabled
Used to group related elements inside form as one Specifies that an <input> element should be
entity and enclose them inside box. disabled.
7. form=”form_id”
<legend> … </legend> Specifies the id of <form> element to which
Specifies caption to the <fieldset> element.
<input> element belongs to.
<label> … </label> 8. formaction=”URL”
Used for assigning label to a field in the form. Specifies URL of the file that will process the
input control when form is submitted(only for
Example type=”submit” and type=”image”).
9. formenctype=”application/x-www-form-
urlencoded | multipart/form-data | text/plain”
<form> Specifies how the form data should be encoded
<fieldset> when submitting it to the server(only for
<legend>Personalia:</legend>
type=”submit” and type=”image”).
Name: <input type="text"><br> 10. formmethod=”get|post”
Email: <input type="text"><br> Defines the HTTP method for sending data to
action URL(only for type=”submit” and
Date of birth: <input type="text">
</fieldset>
type=”image”)
</form> 11. formnovalidate
Defines that form elements should not be
<input> … </input> validated when submitted.
8 | HTML and HTML5 Cheat Sheet by www.SnippetNuggets.com
Type Example
<audio> Defines sound content
<embed> Defines a container for an external
(non-HTML) application
<source> Defines multiple media resources
for media elements (<video> and
<audio>)
<track> Defines text tracks for media
elements (<video> and <audio>)
<video> Defines video or movie