HTML Updated
HTML Updated
HTML Updated
Tag Description
<head> It defines the head of an HTML document that contains non-visible data like
metadata and other information
<body> It defines the body of a webpage and contains everything that you see on the
webpage
<h1> to <h6> These are a group of heading tags used to create heading in a webpage
HTML Doctype
Doctype is a document type declaration to the browser. It appears at the top of the HTML document.
It tells the browser about the standard of HTML or type of markup language. Although it is not necessary
to use it but is a W3C recommendation. Example <!DOCTYPE html>
<html> tag
The <html> tag is the topmost tag in HTML. It is the root of an HTML document. All other tags of the
HTML document lie inside it.
You should always use the lang attribute with the <html> tag. It declares the language of the webpage to
the browsers and search engines.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
</body>
</html>
<head> tag
The <head> tag contains information about the webpage that is not visible to the users. These are
machine-readable information like the script, metadata, title, style sheets, etc.
The head of HTML document may contain <title>, <meta>, <style>, <link>, <base>, <script> and
<noscript> tags.
<body> tag
The <body> tag contains all the visible parts of the webpage. Anything like text, image, audio, video,
animations, etc all lies in the body tag.
Heading tags
Heading tags in HTML are used to create headings on the webpage. There are 6 different types of
heading in HTML h1 to h6.
The headings h1 to h6 are ordered on the basis of their font size and importance. The <h1> defines most
important heading and <h6> defines least important.
There can be only one h1 tag in a webpage and you should not skip any level of heading from h1 to h6.
Example
Paragraph tag
A paragraph in webpage is defined by <p> tag. A paragraph is a block-level element used to represent
text on the browser.
comment tag
While writing code it is a good practice to write a comment about what code is all about. In HTML you
can write comment using <!--...-->.
The comment is written between the double dash, it can be in a single line or multiline comment.
<p>This paragraph is visible on the webpage but comment below is not visible.</p>
<!-- This is
The <br> is used to create a line break in the text. It can be used in writing addresses, song lyrics, or at a
place where a line break is needed.
is used to <br>
</p>
The <hr> is used to create a break between paragraphs using a horizontal line. Using CSS you can modify
and style as per your own need.
Example
<p>Scene 1:</p>
<hr>
<p>Scene 2:</p>
Formatting tags
This is a list of formatting tags in HTML5. It gives us the ability to format the text
without using CSS.
<b> tag
The <b> tag is used to make a word or group of the word special to draw the reader's attention.
The <b> tag format the text to bold. However, you should not use the b tag to make text bold instead
use the font-weight property of CSS.
Example
<strong> tag
The <strong> tag is used to make the content very important or urgent. The browser renders it as bold
content.
However, you should not use the strong tag to make content bold instead use the font-weight property
of CSS.
Example
<i> tag
The <i> tag is used to format the text in an alternative mood or voice to set off from the normal text.
It makes text italic and is used to define technical terms, idiomatic text, etc.
Example
<em> tag
The em tag can be nested and with each nesting emphasis on text increases.
Example
<u> tag
By default, it underlines the text content but it can be changed using CSS.
Example
<p>There are lots of <u>speling</u> mistake in <u>thes</u> line.</p>
<sup> tag
Example
<sub> tag
Example
<pre> tag
The <pre> is also called a preformatted tag. It is used to present text as it is written in an HTML
document.
It renders text using a monospace font. The whitespaces used in the element are displayed the same as
written.
<pre>Y Y
Y Y
Y Y
Y Y
Y Y
YY
Y</pre>
<small> tag
The <small> tag is used to define smaller text like copyright, comments, etc.
By default, it renders text smaller than standard however it can be controlled using CSS.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>small tag</h1>
</body>
</html>
<abbr> tag
The <abbr> tag is used to represent an abbreviation or acronym. The tag accepts a title attribute that
accepts the full form of the word. When the reader hovers the text it shows a full description of the
word.
Example
<code> tag
The <code> tag is used to display computer codes on the webpage. The browser uses some default style
to indicate that this is a code.
You can use CSS to add additional style properties to the tag.
<style>
code {
color: #e83e8c;
background-color: #fff5f5;
</style>
<del> tag
The <del> tag defines texts which have been removed from the document or webpage. It can be used to
track changes to previous versions of code.
The content of the del element has a strikethrough line that cuts the content horizontally in middle.
<ins> tag
The <ins> tag is used to display a group of text which has been added to the document.
Example
<del>
</del>
<ins>
</ins>
<mark> tag
The <mark> tag marks or highlights a text to grab the reader's attention.
According to HTML standards, it is not mandatory to use it, you can achieve it using CSS.
Example
<blockquote> tag
The <blockquote> tag indicates that the enclosed text is extended text from another source.
The URL of the external source is given using the cite attribute.
<!DOCTYPE html>
<html>
<body>
<h1>The blockquote element</h1>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For 50 years, WWF has been protecting the future of nature. The world's leading conservation
organization, WWF works in 100 countries and is supported by 1.2 million members in the United States
and close to 5 million globally.
</blockquote>
</body>
</html>
<s> tag
The <s> tag display text by making a strikethrough with it. It is used to show a specific content is no
longer relevant.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML - s tag</title>
</head>
<body>
<h1>s tag</h1>
</body>
</html>
<address> tag
The <address> tag is used to display the contact or address of a person or an organization.
It can include any kind of information email, phone number, house number, social media, etc.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>address tag</h1>
<address>
Mailto: <a href="mailto:office@example.com">John smith</a><br>
Twitter: 🐦@example_john
</address>
</body>
</html>
<cite> tag
The <cite> tag describes a reference to a cited creative work or art. It must include the title of that work.
Ezoic
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>cite tag</h1>
</body>
</html>
<dfn> tag
The <dfn> tag (definition tag) is used to tell that a term is being defined in the sentence.
When you use <dfn> tag then nearest parent element like <p> or <section> tag should contain the
definition of the term.
Example
<meter> tag
The <meter> tag is used to define a scale with a given range and value.
The tag requires a defined value with min value and max value of the scale. The min, max, and value are
attributes of the tag.
You can also give low and high values to the scale which is used to change the color of the scale. If the
value of the scale is below the low value then the scale is green, if the value is between low and high
then the scale is yellow and if the scale is above the high value then the scale is red.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>meter tag</h1>
</body>
</html>
<progress> tag
The <progress> tag is used to display an indicator to show the completion progress of a task. It is
displayed as a progress bar.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>progress tag</h1>
</body>
</html>
<q> tag
The <q> tag defines an inline quotation. The most modern browser automatically adds quotation marks
around the text.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML - q tag</title>
</head>
<body>
<h1>q tag</h1>
</body>
</html>
<samp> tag
The <samp> tag defines a sample of computer output from a computer program.
The browser renders the content by using default style like the monospaced font.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>samp tag</h1>
</html>
<template> tag
The <template> tag is a less known but very useful tag. It is used to hold the HTML code which is not
rendered on the screen. You can use these codes later using javascript.
You can think of it as a container where you can store HTML code and then later fetch it using javascript
and read it somewhere else.
The HTML code inside the template tag is not rendered by is processed by the parser to ensure the
validity of the code.
The <template> HTML element is a mechanism for holding HTML that is not to be rendered immediately
when a page is loaded but may be instantiated subsequently during runtime using JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>template tag</h1>
<template id="moreLang">
<li>JavaScript</li>
<li>Python</li>
</template>
<ul id="langList">
<li>C</li>
<li>C++</li>
</ul>
<script>
function addMoreLang() {
langList.appendChild(clone);
</script>
</body>
</html>
<time> tag
The <time> tag used to represent time in HTML. It contains a datetime attribute that stores the exact
date and time of an event, which is used by search engines to provide better results.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>time tag</h1>
</body>
</html>
<var> tag
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>var tag</h1>
</body>
</html>
3. Image tags
<img> tag
The img tag accepts the URL of the image by the src attribute. You can also provide alt text (alternative
text) used when the image does not exist.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
</body>
</html>
<figure> tag
The <figure> behaves like a container for images and also gives an option for the image caption defined
by <figcaption>.
The figure tag makes the image, its caption and other of its content a single unit.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
figure {
padding: 5px;
width: fit-content;
}
</style>
</head>
<body>
<h1>figure tag</h1>
<figure>
<figcaption>Image of a cat</figcaption>
</figure>
</body>
</html>
<figcaption> tag
The <figcaption> tag is used to create a caption for an image inside the <figure> tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
figure {
padding: 5px;
width: fit-content;
figcaption {
padding: 10px;
text-align: center;
background: gray;
</style>
</head>
<body>
<h1>figcaption tag</h1>
<figure>
<figcaption>Image of a cat</figcaption>
</figure>
</body>
</html>
<picture> tag
The <picture> is used to define hold multiple sources of an image. It contains 0 or more <source>
element and 1 <img>.
The multiple resources of the image are chosen in different scenarios and the image source from the
<img> tag is used when no other source is available or supported.
The <img> is also used to provide the alt attribute and width of the image.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>picture tag</h1>
<p>Adjust the window size at 600px and see how the browser chooses different source of image for
different scenario.</p>
<picture>
</picture>
</body>
</html>
he <picture> tag gives web developers more flexibility in specifying image resources.
The most common use of the <picture> element will be for art direction in responsive designs. Instead of
having one image that is scaled up or down based on the viewport width, multiple images can be
designed to more nicely fill the browser viewport.
The <picture> element contains two tags: one or more <source> tags and one <img> tag.
The browser will look for the first <source> element where the media query matches the current
viewport width, and then it will display the proper image (specified in the srcset attribute). The <img>
element is required as the last child of the <picture> element, as a fallback option if none of the source
tags matches.
<map> tag
The <map> is used to define area elements to create a map-like clickable structure inside an image.
<area> tag
The <area> is used to define an area inside an image and create a clickable link. It uses attributes to
define shape, coordinates, URL, etc.
href - It provides the URL of the hyperlink for the target area
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>area tag</h1>
<map name="yourMap">
</map>
</body>
</html>
<canvas> tag
The <canvas> tag was introduced in HTML5. It is used to create controllable graphics and animations.
Using canvas you can create anything from a simple animation to a complex game.
You need javascript to create anything inside the canvas. The default dimension of the canvas is 300 ×
150.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
canvas {
</style>
</head>
<body>
<canvas id="myCanvas"></canvas>
<script>
ctx.fillStyle = "yellow";
ctx.fillStyle = "red";
</script>
</body>
</html>
<svg> tag
The <svg> is also known as scalable vector graphics. It is used to create different geometrical shapes like
circles, rectangles, lines, curve paths, vector images, etc.
SVG can create very complex images and are very lightweight. Components of these images can be
easily handled by CSS and javascript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
</svg>
</body>
</html>
These HTML tags are used to create any hyperlink, define connections with other resources, or create a
navigation menu.
Tag Description
<link> It defines connects other document with HTML documents or defines some relationship
<a> tag
The <a> tag also known as anchor tag is used to create a hyperlink to another webpage.
The URL of the hyperlink is given as href attribute. The browser renders the link text underlined and blue
color.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML - a tag</title>
</head>
<body>
</body>
</html>
<link> tag
The <link> is used to create a relationship between a current document and any external document. It is
mostly used to add an external stylesheet to the HTML files.
It is used inside the <head> tag. Apart from stylesheets, it is also used to add favicon icons to web pages
and mobile devices.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<h1>link tag</h1>
</html>
<nav> tag
The <nav> defines a section of the page that has navigation links, either internal links or external links.
It can be used in creating menus, a sidebar with multiple links, footer links, etc.
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
5. List tags
Following is the HTML tags list for creating ordered, unordered, and description lists in HTML.
Tag Description
<ol> tag
The <ol> tag defines an ordered list of items. It behaves like a container for a list item that is listed in
order.
The default order of <ol> tag is 1, 2, 3... and so on. While you can use the type attribute to set different
types of numbering.
<body>
<ol>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ol>
<ol type="A">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ol>
</body>
<ul> tag
The <ul> tag defines unordered list. It behaves like a container for unordered list items.
The unordered list items are rendered as bullet items however they can be changed using the type
attribute.
type="circle"
type="disc"
type="square"
<body>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
<ul type="square">
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</body>
<li> tag
The <li> tag is used to create list items for all types of lists.
<body>
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
</body>
<dl> tag
Description list contains a list of groups of the term specified by <dt> and their descriptions specified by
<dd>.
<dt> tag
The <dt> tag defines a description term in description list. It must lie inside <dl> tag.
<dd> tag
The <dd> tag defines description for a term in description list. It is proceeding term of <dd> tag and lies
inside <dl> tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML - dl tag</title>
</head>
<body>
<dl>
<dt>HTML</dt>
<dt>CSS</dt>
<dt>JavaScript</dt>
</dl>
</body>
</html>
Form and input tags
Tag Description
<datalist> It provides control to select among multiple options as well as to submit your own new
option
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form>
<closeform></closeform></form>
</body>
</html>
<input> tag
The <input> tag is used to create an input component in the web pages. It needs a type attribute to tell
the browser what type of data this input component will accept.
The default value of type attribute is text. The type attribute can have many different values as shown in
the list:
type="text"
type="number"
type="email"
type="password"
type="file"
type="submit"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form>
<closeform></closeform></form>
</body>
</html>
<label> tag
The <label> tag defines a caption for an item on the webpage. It is generally used for input elements.
The label text with input elements is not only visually associated but also programmatically associated.
When you click the text of the label element its corresponding input activates.
Use for an attribute in the label tag and give the same value to the ID of the element you want to
associate with.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form>
<label for="name">Name:</label>
<label>Age:
<input type="number">
</label>
<closeform></closeform></form>
</body>
</html>
<textarea> tag
The <textarea> tag defines a multiline user input component. It allows the user to adjust its size.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form>
<label for="feedback">Feedback:</label>
<textarea id="feedback"></textarea><br>
<input type="submit" value="submit">
<closeform></closeform></form>
</body>
</html>
<option> tag
The <option> tag defines a an item to be selected in <select>, <optgroup> or <datalist> elements.
<select> tag
The <select> tag defines a control for a menu to choose one element from multiple options.
You can associate a label tag with it. When you click the control a menu will open from which you can
choose one item.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<option value="HTML">HTML</option>
<option value="CSS">CSS</option>
<option value="javascript">JavaScript</option>
</select>
</body>
</html>
<optgroup> tag
The <optgroup> tag is used to create a group of option in the <select> tag.
<body>
<select id="lang">
<option value="HTML">HTML</option>
<option value="CSS">CSS</option>
</optgroup>
<option value="javascript">JavaScript</option>
<option value="Python">Python</option>
<option value="PHP">PHP</option>
</optgroup>
</select>
</body>
<fieldset> tag
The <fieldset> tag is used to group several labels and inputs in a form.
<legend> tag
The <legend> tag defines a caption for the content of its parent element.
<body>
<form>
<fieldset>
<legend>Personal data</legend>
</fieldset>
<fieldset>
<legend>Academic data</legend>
</fieldset>
<br>
<closeform></closeform></form>
</body>
<datalist> tag
The <datalist> tag defines a control that lets you choose one item from a menu and gives you the ability
to submit something other than the menu item.
<body>
<h1>datalist tag creates a control to select one item from multiple and also gives ability to submit own
item.</h1>
<form>
<input list="languages">
<datalist id="languages">
<option value="HTML">HTML</option>
<option value="CSS">CSS</option>
<option value="javascript">JavaScript</option>
</datalist>
</label>
<closeform></closeform></form>
</body>
<button> tag
The <button> tag is used to create a clickable button in HTML, that can trigger some even or submit a
form.
In a form when you give type="submit" then it becomes submit button for the form.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<form>
<closeform></closeform></form>
</body>
</html>