HTML Tutorial
HTML Tutorial
beginners
HTML is a markup language that creates webpage layout. There are at least 1.2
billion websites online today and all are designed by using HTML. Take our HTMl tutorial
and get a complete basic guide for beginners.
If you are interested in developing websites, then, gaining an in-depth knowledge of HTML
is the first step. Only after that you can start CSS and JavaScript coding.
We have created this HTML Tutorial for beginners with practical examples for every topic.
So, go through this complete HTML tutorial and start climbing the ladder of a beautiful Web
Designing journey.
In our previous article we gave a brief introduction to What is HTML?. We also talked about
some prerequisites and popular HTML Editors. We suggest you to first read that article and
then continue with this tutorial.
Useful Read: Full Stack Development – Steps to Become a Full Stack Developer .
Contents
1: Is HTML a programming language?
2: Short HTML History
3: Features of HTML
4: Advantages of Learning HTML
5: Your first HTML webpage
6: Microsoft Word as HTML Editor?
7: HTML Versions Timeline
Is HTML a programming language?
HTML is called as a markup language that is different from a programming language. Its full
form is Hypertext Markup Language. Now, What is a markup language?, What is Hypertext?
How is it different from programming language? Let's explain each term and start our HTML
tutorial:
Hypertext: Hypertext means, text with a link embedded in it. If you click on that link,
it will open a new webpage. Apart from text, hypertext may contain HTML
tables, HTML lists, HTML forms, HTML images, etc.
Markup language: Markup language uses tags to define elements within a document.
It contains familiar words that are human-readable like forms, tables, links, titles, etc.
Every tag in a markup language has a special meaning of its own and performs a
particular operation.
In conclusion, HTML is not a programming language. A programming language uses logic to
produce a result, it use conditional statements, variables, functions, etc. Whereas HTML is a
markup language, that create structures using tags for the data presentation. There is no logic
or algorithm involved.
<!DOCTYPE html>
<html lang="en">
<HTML>
<head>
<title> Page Title </title>
</head>
<body>
<h1> This is a Heading </h1>
<p> This is a Paragraph </p>
</body>
</html>
Output
This is a Heading
This is a Paragraph
Explanation of HTML tags used in the Example
<!DOCTYPE>- The doctype declaration indicates the document type and version of
HTML used on the webpage. Each version has a different doctype declaration.
HTML5 Doctype is used in this example.
<html>- It is the root tag that describes the whole webpage. It is a paired tag, i.e., it
has a closing tag also, </html>. Everything will be written inside these tags.
<head>- Head tag contains information about the document like its title, author
information, description of the webpage, and so on. It has different tags to perform
these functions. It is also a paired tag.
<title>- Title tag is used inside <head>, and it specifies the title of the document.
<body>- The body tag contains all the information which will be displayed on the
webpage. If you want anything to be displayed on the webpage, you have to write it
within these tags.
<h1>- Heading tag is used to define headings. <h1> is the largest heading, followed
by <h2>, <h3>, to <h6>.
You can try our online HTML editor and can make changes accordingly.
HTML 1991
XHTML 2000
HTML 5 2014
Frequently Asked Questions
Do all website use HTML?
Yes, all the websites present on the internet use HTML for their layout. Even different CMS,
like wordpress, magento, etc, where coding knowledge is not necessary, also use it to design
websites.
What is Hypertext?
A HyperText is a text that contain a link to some other text or webpage. Hypertext document
is a the one the contain Hyperlinks. HyperText is also sometimes used to define tables,
images, etc with integrated Hyperlinks.
<html> </html>
<table> </table>
<form> </form>
<span> </span>
<ul> </ul>
<p> </p>
<head> </head>
Open Tag Close Tag
<div> </div>
<br>
<hr>
<meta>
<input>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Heading Tag </title>
</head>
<body>
<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>
</body>
</html>
Output
This is Heading 1
This is Heading 2
This is Heading 3
This is Heading 4
This is Heading 5
This is Heading 6
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Paragraph Tag </title>
</head>
<body>
<p> This is First Paragraph </p>
<p> This is Second Paragraph </p>
<p> This is Third Paragraph </p>
</body>
</html>
Output
This is First Paragraph
This is Second Paragraph
This is Third Paragraph
<!DOCTYPE html>
<HTML lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Anchor Tag </title>
</head>
<body>
<a target="_blank" href="https://www.coderepublics.com"> This is a link </a>
</body>
</html>
Output
This is a link
Note : Use 'target = _blank' as an attribute in <a> tag to open the link in a new tab.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Tag </title>
</head>
<body>
<img src="HTML-Image.png" width="400px" height="200px">
</body>
</html>
Output
A
<a> Creates hyperlink.
B
<b> It makes text bold.
<base> It defines a base URL for all relative URL within the document.
C
<canvas> It creates a graphics space.
D
<datalist> It defines a predefined list for input option.
E
<em> It emphasizes text content.
F
<fieldset> It groups related elements/labels within a web form.
H
<h1> to <h6> It defines headings' sizes from level 1 to 6.
Hope this tutorial will help you to understand the fundamentals of HTML tags. There is one
more concept of elements vs Tags in HTML. To learn more about HTML Element vs HTML
tags we suggest you to go WikiPedia page.
HTML Attributes
HTML attribute defines the characterstics of any HTML element. These attributes provide
additional information to the browser about the element like, its size, color, behaviour, etc.
You can check all the values of lang attribute for different languages from here.
ExampleTry this code »
<!DOCTYPE html>
<HTML lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Lang Attribute </title>
</head>
<body>
<p> This page is using English Language. </p>
</body>
</html>
Output
This page is using English Language.
Adding tooltips using Title attribute, is a smart way to give brief explanations about some
element on the webpage. Look at the example below, to see how you can use it with
any HTML tag.
<!DOCTYPE html>
<HTML lang="en">
<head>
<meta charset="UTF-8">
<title> The Title Attribute </title>
</head>
<body>
<h3 title= "Hello HTML"> The Example of Title Attribute </h3>
</body>
</html>
Output
WHO was founded in 1948.
CodeRepublics.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Alt Attribute </title>
<body>
<img src="HTML-Image.png" alt="HTML5 Image" style="width:400px; height:250px;">
</body>
</html>
If a browser cannot find an image, it will display the value of the alt attribute :
Output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Inline Styles </title>
</head>
<body>
<h4 style="color:green"> This is Green Color </h4>
<h4 style="color:blue"> This is Blue Color </h4>
</body>
</html>
Output
This is Green Color
This is Blue Color
All the formatting tags are paired tags. Anything written between any formatting tag will be
displayed according to the tag in the browser. For example, anything written
between <i> and </i> will display as italic text in the browser.
There are different tags for various formatting tags. Each Tag has its own type of formatting
associated with it.
o Bold Tag <b>
o Italic Tag <i>
o Underline Tag <u>
o Strong Tag <strong>
o Small Tag <small>
o Big Tag <big>
o Mark Tag <mark>
o Emphasized Tag <em>
o Deleted Tag <del>
o Inserted Tag <ins>
o Subscripted Tag <sub>
o Superscripted Tag <sup>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Bold Text </title>
</head>
<body>
<p> This is Normal text. </p>
<b> This is Bold Text. </b>
</body>
</html>
Output
This is normal text.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Strong Text </title>
</head>
<body>
<p> This is Normal text </p>
<strong> This Text is Strong </strong>
</body>
</html>
Output
This is Normal text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Italic Text </title>
</head>
<body>
<p> This is normal text </p>
<i> This is italic Text </i>
</body>
</html>
Output
This is normal text
Underlined Text is used to draw attention of the user and is a default formatting for a
hyperlinked text.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Underlined Text </title>
</head>
<body>
<p> This is Normal text </p>
<u> This is Underlined Text </u>
</body>
</html>
Output
This is Normal text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Small Text </title>
</head>
<body>
This text is <small> small </small>.
</body>
</html>
Output
This text is small .
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Big Tag </title>
</head>
<body>
This text is <big> BIG </big>
</body>
</html>
Output
This text is BIG
HTML Marked Text
The HTML <mark> Tag defines Highlighted text. The text will have a background color and
represent relevancy in an HTML document.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Mark Tag </title>
</head>
<body>
This text is <mark> Marked. </mark>
</body>
</html>
Output
This text is Marked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Emphasize Text </title>
</head>
<body>
This text is Normal.
This text is <em> Emphasized. </em>
</body>
</html>
Output
This text is Normal.
This text is Emphasized.
HTML Deleted Text
The HTML <del> element defines Deleted text. This displays Text with a line strike.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Delete Text </title>
</head>
<body>
<p> This text is Normal. </p>
This text is <del> Deleted. </del>
</body>
</html>
Output
This text is Normal.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Insert Text </title>
</head>
<body>
This text is <ins> inserted. </ins>
</body>
</html>
Output
This text is inserted.
HTML Subscripted Text
The HTML <sub> element defines subscripted text. This type of text is small in size and is placed
slightly below the normal line of text.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Subscript Text </title>
</head>
<body>
This text is <b> bold. </b>
This text is <i> italic. </i>
This text is <sup> Subscripted. </sup>
</body>
</html>
Output
This text is bold.
This text is italic.
This text is Subscripted.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Superscript Tag </title>
</head>
<body>
This text is <b> bold. </b>
This text is <i> italic. </i>
This text is <sup> Superscripted.
</body>
</html>
Output
This text is bold.
This text is italic.
This text is Superscripted.
<h1> gives the largest heading and <h6> gives the smallest one. So <h1> can be used for most
important headings and <h6> can be used for least important one.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Heading Tag </title>
</head>
<body>
<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>
</body>
</html>
Output
This is Heading 1
This is Heading 2
This is Heading 3
This is Heading 4
This is Heading 5
This is Heading 6
Heading Size
You can change the size of Heading by using font-size property.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Heading Tag </title>
</head>
<body>
<h1 style="font-size:50px;">Heading 1</h1>
<p>You can change the size of a heading with the style attribute, using the font-size
property.</p>
</body>
</html>
Output
Heading 1
You can change the size of a heading with the style attribute, using the font-size property.
You can add Style or JavaScript between head tags and make you web page more
interactive.
A <p> tag is very important, as all the content written on a website needs to get formatted in
the form of paragraphs. Browsers automatically add blank lines above and below a
paragraph. It separates a paragaph from other content or other paragraphs on the page.
HTML Paragraphs are block level elements, i.e., a new paragraph will always start from a
new line. Also, p tags gets automatically closed if another block-element gets inserted before
the </p> tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Paragraph Tag </title>
</head>
<body>
<p> This is First Paragraph </p>
<p> This is Second Paragraph </p>
<p> This is Third Paragraph </p>
</body>
</html>
Output
This is First Paragraph
This is Second Paragraph
You can add spaces and new lines on a paragraph by using <pre> tag but don't practice it
immaturely. The spaces will look poor on the website. In the example below, as you can see
in the results, all the space is ignored by the browser.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Paragraph Tag </title>
</head>
<body>
<p> This is First Paragraph. </p>
<p> This is Second Paragraph. </p>
<p> This is Third Paragraph.</p>
</body>
</html>
Output
This is First Paragraph.
The pre tag is a paired tag; it displays text as it was written within the tag. Browser won't
omit consecutive spaces or line breaks. It is used to display a block of code of a programming
language or to display a poem with proper line breaks.
In the example below, you can see that the text is displayed as it is, in the browser, as it was
written inside the pre tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Pre Tag </title>
</head>
<p>The pre tag preserves both spaces and line breaks:</p>
<pre>
This is a Paragraph Tag.
This is a Paragraph Tag.
This is a Paragraph Tag.
This is a Paragraph Tag.
</pre>
</body>
</html>
Output
This is a Paragraph Tag.
Note: If you want to add some extra space outside the paragraph, then don't use <br> tag.
Instead, use CSS Margins to change the space above/below the paragraph.
The <a> tag is a paired tag with </a> tag as a closing tag. Whatever is written between these
two tags will feature as a hyperlink on the webpage.
The href attribute in HTML is used in a tag to give the reference(location URL) of other
webpage. The full form of href is Hypertext REFerence. In simple words you just have to
paste the url of the webpage in href, that you want to link.
<a href="url">link text</a>
In the example below, the text "Visit our HTML tutorial" will work as a hyperlink and will
take the user to our html tutorial page. We have given the address(Path) of that page as a
reference in thehref attribute.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Anchor Tag </title>
</head>
<body>
<a href="https://www.coderepublics.com"> Welcome to CodeRepublics </a>
</body>
</html>
Output
Visit our HTML tutorial
Value Description
target="_self" Opens the linked document in the same window/tab. This is the default value
target="_top" Opens the linked document in the full body of the window.
Note: HTML Frames are deprecated in HTML 5 and it is recommended not to use them.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Anchor Tag Example </title>
</head>
<body>
<p><a href="https://www.coderepublics.com" target="_blank">Welcome to
CodeRepublics</a></p>
<p><a href="https://www.coderepublics.com" target="_top">Welcome to
CodeRepublics</a></p>
<p><a href="https://www.coderepublics.com" target="_parent">Welcome to
CodeRepublics</a></p>
<p><a href="https://www.coderepublics.com" target="_top">Welcome to
CodeRepublics</a></p>
</body>
</html>
Output
Welcome to CodeRepublics
Welcome to CodeRepublics
Welcome to CodeRepublics
Welcome to CodeRepublics
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Link </title>
</head>
<body>
<p>The image is a link. You can click on it.</p>
<a href="https://www.coderepublics.com">
<img src="PUBG.png" alt="HTML Image" style="width:300px;height:200px;">
</a>
</body>
</html>
Output
As you can see, in the example above, The <img> tag is used within the <a> tag. This nested
structure created the whole image as a hyperlink.
You can create a base path of your Base Domain. Whenever you give reference to any link,
you can skip the base domain and can directly write latter part. Browser will automatically
concatenate the link with the base path you have given and will make a complete URL.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Base Path Link Example</title>
<base href="https://www.Coderepublics.com" target="_blank">
</head>
<body>
<p> Click following link </p>
<a href="https://www.coderepublics.com/HTML/html-tutorial.php"> Learn HTML </a>
</body>
Output
Welcome to GeekRepublics
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Change Link Color </title>
</head>
<body alink="green" vlink="red">
<p> Click following link </p>
<a href="https://geekrepublics.com/"> Welcome to GeekRepublics </a>
</body>
Output
Welcome to GeekRepublics
Note : The alink attribute is not supported in HTML5. Use CSS instead.
Images are a necessary part of writing rich content on the internet. They help in easy reading.
They are the face of content on internet, especially on social media.
You can add thumbnail images for social media using meta tags, which we will discuss in
meta tag tutorial. Today we will discuss about inserting images within the body of a web
page.
The <img> tag has a specified syntax with different attributes to control image behaviour.
Look at the syntax below:
Syntax
Example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Tag </title>
</head>
<body>
<img src="HTML-Image.png" width="400px" height="200px">
</body>
</html>
Output
The img src attribute
The src attribute in img tag specify the location of the image. You have to provide a complete
path of the image to insert it into the web page.
If your image and your web page are in the same folder, then you can insert it using only its
name with extension, like, src="flower.jpg".
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Alt Attribute </title>
<body>
<img src="HTML-Image.png" alt="HTML5 Image" style="width:400px; height:250px;">
</body>
</html>
The information written in alt attribute is useful for search engines. It helps them to
understand the content present in the image. So, images can rank in google image search and
drive traffic.
alt attribute
is also helpful for screen readers. When they encounter an image within
webpage they describe the image through text written in alt attribute.
One more important feature is that if the image fails to load, then the browser displays alt text
in place of it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Alt Attribute </title>
<body>
<img src="HTML-Image.png" alt="HTML5 Image" style="width:400px; height:250px;">
</body>
</html>
Output
It is advised to alter the actual image size according to website requirements. If you resize an
image using width and height attributes, then it can stretch the image, which will look
unpleasant.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Image Size Attribute </title>
<body>
<img src="HTML5-Image.png" alt="HTML5 Image" width=600px height=250px>
</body>
</html>
Output
Today we will learn about all HTML table tags that will help you to create a table for your
data.
<!DOCTYPE html>
<html lang="en">
<HTML>
<head>
<meta charset="UTF-8">
<title> HTML Table </title>
</head>
<body>
<table>
<tr>
<th> Name </th>
<th> Salary </th>
<th> Age </th>
</tr>
<tr>
<td> Anshuman </td>
<td> Rs. 2,00,000 </td>
<td> 25 </td>
</tr>
<tr> <td> Kuldeep </td>
<td> Rs. 5,00,000 </td>
<td> 22 </td>
</tr>
</table> </body>
</html>
Output
Name Salary Age
Rs.
Anshuman 25
2,00,000
Rs.
Kuldeep 22
5,00,000
To create a new row, add another <tr> tag after closing the previous one.
It can only be used inside &glt;tr> or <td> tags. After declaring rows, the <td> tags are used
to enter data in the table. Whatever is written inside the <td> and </td> tags will be displayed
by the browser in the tables as it is.
HTML Table Attributes
The <table> Tag in HTML has many attributes that define the structure of the table. These
attributes can make a table look a bit more attractive. Let’s see one by one the different
attributes of the table tag and then we will use them in an example and will see the changes in
the table.
The table border attribute has two values 0 and 1. 0 means no border and 1 means visible
borders. You can also increase the values to 2, 3, 4, etc. it will increase the width of the
border.
Look at the example below to define an HTML border with border attribute:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Table Border Attribute </title>
</head>
<body>
<table border="1" width="100%">
<tr>
<th> Name </th>
<th> Salary </th>
<th> Age </th>
</tr>
<tr>
<td> Anshuman </td>
<td> Rs. 2,00,000 </td>
<td> 25 </td>
</tr>
<tr>
<td> Kuldeep </td>
<td> Rs. 5,00,000 </td>
<td> 22 </td>
</tr>
</table>
</body>
</html>
Output
Name Salary Age
Anshuman Rs. 2,00,000 25
Kuldeep Rs. 5,00,000 22
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Table Border Style </title>
<style>
table, th, td {
border: 1px solid black;
text-align: center;
}
</style>
</head>
<body>
<table width="100%">
<tr>
<th> Name </th>
<th> Salary </th>
<th> Age </th>
</tr>
<tr>
<td> Anshuman </td>
<td> Rs. 2,00,000 </td>
<td> 25 </td>
</tr>
<tr>
<td> Kuldeep </td>
<td> Rs. 5,00,000 </td>
<td> 22 </td>
</tr>
</table>
</body>
</html>
Output
Name Salary Age
Anshuman Rs. 2,00,000 25
Kuldeep Rs. 5,00,000 22
As you increase the value, the space between the cell’s content and its border also increases.
The default value of cellpadding is taken in pixels by browsers. The cellpadding is applied to
all the four sides of the content. The value can also be defined in percentages.
Cellspacing attribute
The Cellspacing attribute is used to specify the space between the cells of the table. Its value
can be in pixels or in percentages. It is applied to all the sides of the cells.
Note: These two attributes are no longer a part of HTML 5. So, it is better to use CSS to
color the tables.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Table Cellpadding Attribute </title>
</head>
<body>
<table border="1" cellpadding="5" cellspacing="5" style="width:100%">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Peter</td>
<td>5000</td>
</tr>
<tr>
<td>John</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
Output
Name Salary
Peter 5000
John 7000
These two attributes are used to merge two or more columns or rows. Table colspan
attribute’s value suggest the amount of column space it will occupy. For example ‘<td
colspan= 2>’ will create a cell taking space of two cells horizontally i.e. it will occupy the
space of a cell of the next column.
Similarly, Table rowspan will create a cell which will occupy the space of two or more (as
specified) cells vertically, i.e. cells of the next rows. Look at the example below to
understand the concept clearly.
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
<h2>Cell that spans two rows:</h2>
<table style="width:100%">
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>9998887776</td>
</tr>
<tr>
<td>9998887776</td>
</tr>
</table>
</body>
</html>
Output
Name: Bill Gates
9998887776
Telephone:
9998887776
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Table Colspan Attribute </title>
</head>
<body>
<table border="1" width="80%">
<tr>
<th> Person_Name </th>
<th colspan="2"> Mobile </th>
</tr>
<tr>
<td> Bill Gates </td>
<td> 9998887776 </td>
<td> 9998887775 </td>
</tr>
</table>
</body>
</html>
Output
Person_Name Mobile
Bill Gates 9998887776 9998887775
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Table Caption Attribute </title>
<style>
table, th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<table>
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
</body>
</html>
Output
Monthly savings
Month Savings
January $100
February $50
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Font Size </title>
</head>
<body>
<font size="1">Hello HTML 5!</font>
<font size="2">Hello HTML 5!</font>
<font size="3">Hello HTML 5!</font>
<font size="4">Hello HTML 5!</font>
<font size="5">Hello HTML 5!</font>
<font size="6">Hello HTML 5!</font>
<font size="7">Hello HTML 5!</font>
</body>
</html>
Output
Hello HTML 5!
Hello HTML 5!
Hello HTML 5!
Hello HTML 5!
Hello HTML 5!
Hello HTML 5!
Hello HTML 5!
Explain: As you can see that, as the number increase the html font size will also increase.
The Font Face
You can set font face using 'face' attribute but be aware that if the user viewing the page
doesn't have the Font installed, they will not see it. Instead, the user will see the default font
style.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Font Face Attribute </title>
</head>
<body>
<font face="Times New Roman" size="5">Times New Roman</font>
<font face="Verdana" size="5">Verdana</font>
<font face="Comic sans MS" size="5">Comic Sans MS</font>
<font face="WildWest" size="5">WildWest</font>
<font face="Bedrock" size="5">Bedrock</font>
</body>
</html>
Output
Times New Roman
Verdana
Comic Sans MS
WildWest
Bedrock
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Font Face Alternative Attribute </title>
</head>
<body>
<font face="Times New Roman,Verdana,Comic sans MS,WildWest" size="5">Times New
Roman</font><br />
<font face="Lucida Calligraphy,Comic Sans MS,Lucida Console" size="5">Bedrock</font>
</body>
</html>
Output
Times New Roman
Bedrock
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>HTML Font Color</title>
</head>
<body>
<font color="#69C">This text is in Blue</font><br />
<font color="green">This text is Green</font>
</body>
</html>
Output
This text is in Blue
This text is Green
Well, as I said before, that html color is no longer used in HTML 5, so if you are working on
an older version of HTML, then you can use the HTML font color tag as needed. Also, you
can choose and add color code from the color picker tool.
rdered List in HTML
This list is created by using <ol> tag. Any series can be used to order the elements, like series
of digits, alphabets, roman numerals, etc. All these series gets increased by one with every
new element entered in the list.
Ex.-For a numbered order list, the numbering starts at one and is incremented by one for each
successive ordered list element tagged with <li>. Have a look at the example below to
understand the concept properly.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Ordered List </title>
</head>
<body>
<h2>HTML Ordered list</h2>
<ol>
<li>Audi</li>
<li>Mercedes</li>
<li>Lamborghini</li>
</ol>
</body>
</html>
Output
1. Audi
2. Mercedes
3. Lamborghini
Value Description
type="I" The list items will be numbered with uppercase roman numbers.
type="i" The list items will be numbered with lowercase roman numbers.
List of Numbers
Numbers as type - <ol type="1">. Here the numbers will be used to order the elements. Each
new element will get incremented value from the previous one in the list.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Ordered List </title>
</head>
<body>
<h2>HTML Ordered list</h2>
<ol>
<li>Audi</li>
<li>Mercedes</li>
<li>Lamborghini</li>
</ol>
</body>
</html>
Output
1. Audi
2. Mercedes
3. Lamborghini
Uppercase
Uppercase alphabets as type - <ol type="A">. Here, Uppercase alphabets will be used to
order the elements.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Ordered List Uppercase </title>
</head>
<body>
<ol type="A">
<li>Audi</li>
<li>Mercedes</li>
<li>Lamborghini</li>
</ol>
</body>
</html>
Output
A. Audi
B. Mercedes
C. Lamborghini
Lowercase
Lowercase alphabets as type - <ol type="a">. Same as above, but the alphabets will be
lowercased.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Ordered List Lowercase </title>
</head>
<body>
<ol type="a">
<li>Audi</li>
<li>Mercedes</li>
<li>Lamborghini</li>
</ol>
</body>
</html>
Output
a. Audi
b. Mercedes
c. Lamborghini
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Ordered List Uppercase Roman </title>
</head>
<body>
<ol type="I">
<li>Audi</li>
<li>Mercedes</li>
<li>Lamborghini</li>
</ol>
</body>
</html>
Output
I. Audi
II. Mercedes
III. Lamborghini
Output
i. Audi
ii. Mercedes
iii. Lamborghini
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Ordered List Start Attribute </title>
</head>
<body>
<ol start="50">
<li>Samsung</li>
<li>OnePlus</li>
<li>Nokia</li>
</ol>
<ol type="I" start="50">
<li>Oppo</li>
<li>Vivo</li>
<li>Xiaomi</li>
</ol>
</body>
</html>
Output
1. Samsung
2. OnePlus
3. Nokia
I. Oppo
II. Vivo
III. Xiaomi
Look at the example below to understand how to use HTML Unordered List:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Unordered List </title>
</head>
<body>
<h2> Unordered List </h2>
<ul>
<li> Harley-Davidson </li>
<li> Ducati </li>
<li> BMW </li>
</ul>
</body>
</html>
Output
Harley-Davidson
Ducati
BMW
Unorder List Type Attribute
The type attribute is used to change the series type.
Value Description
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Unordered List Disc Attribute </title>
</head>
<body>
<h2> Unordered List </h2>
<ul type="disc">
<li> Harley-Davidson </li>
<li> Ducati</li >
<li> BMW </li>
</ul>
</body>
</html>
Output
Harley-Davidson
Ducati
BMW
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Unordered List Circle Attribute </title>
</head>
<body>
<h2> Unordered List </h2>
<ul type="circle">
<li> Harley-Davidson </li>
<li> Ducati </li>
<li> BMW </li>
</ul>
</body>
</html>
Output
o Harley-Davidson
o Ducati
o BMW
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Unordered List Square Attribute </title>
</head>
<body>
<h2> Unordered List </h2>
<ul type="square">
<li> Harley-Davidson </li>
<li> Ducati </li>
<li> BMW </li>
</ul>
</body>
</html>
Output
Harley-Davidson
Ducati
BMW
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Unordered List None Attribute </title>
</head>
<body>
<h2> Unordered List </h2>
<ul type="none">
<li> Harley-Davidson </li>
<li> Ducati </li>
<li> BMW </li>
</ul>
</body>
</html>
Output
Harley-Davidson
Ducati
BMW
Description List
The HTML and XHTML support another list style which is called definition lists where
entries are listed like in a dictionary. The definition list is the ideal way to present a list of
terms, or other name/value list.
The definition list created using <dl> tag. The Description <dt> — defines the item in the list,
and <dd> describes the items in the list.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Definition List</title>
</head>
<body>
<h1>HTML Definition List</h1>
<dl>
<dt>PUBG</dt>
<dd>PlayerUnknown's Battlegrounds (PUBG) developed by PUBG Corporation.</dd>
<dt>God Of War</dt>
<dd>God of War developed by Santa Monica Studio.</dd>
</dl>
</body>
</html>
Output
PUBG
PlayerUnknown's Battlegrounds (PUBG) developed by PUBG Corporation.
God Of War
God of War developed by Santa Monica Studio.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Definition List </title>
</head>
<body>
<dl>
<dt><b>PUBG</b></dt>
<dd>PlayerUnknown's Battlegrounds (PUBG) developed by PUBG Corporation.</dd>
<dt><b>God Of War</b></dt>
<dd>God of War developed by Santa Monica Studio.</dd>
</dl>
</body>
</html>
Output
PUBG
PlayerUnknown's Battlegrounds (PUBG) developed by PUBG Corporation.
God Of War
God of War developed by Santa Monica Studio.
HTML Forms
An HTML form is a section of a document which contains different fields like
text fields, password fields, checkboxes, radio buttons, submit button, menus etc.
HTML Forms can be used where we want to collect some data from the site visitor. For
example, in case of user registration you would like to collect information such as name,
email address, Phone number, etc.
A form will take input and then store it to a back-end application such as CGI, ASP Script or
PHP script etc. The back-end application will perform required processing on the passed data
like storing it in database.
Syntax:
<form>
....
Form Elements..
....
</form>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Input Attribute </title>
</head>
<body>
<h2>Text Input</h2>
<form>
First name:
<input type="text" name="firstname">
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
Output
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Select Attribute </title>
</head>
<body>
<form action="action-page.php">
<select name="Cars">
<option value="Audi"> Audi </option>
<option value="Mercedes"> Mercedes </option>
<option value="Lamborghini"> Lamborghini </option>
</select>
<input type="submit">
</form>
</body>
</html>
Output
Submit
Note : The action attribute defines the action to be performed when the form is submitted.
You should add the destination where the form is submitted.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Textarea Attribute </title>
</head>
<body>
<h2>Textarea</h2>
<p>The textarea element defines a multi-line input field.</p>
<form action="action-page.php">
<textarea name="message" rows="5" cols="60"> This is a simple Example of Textarea.
</textarea>
<br>
<input type="submit">
</form>
</body>
</html>
Output
Submit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Button Attribute </title>
</head>
<body>
<button type="button" onclick="alert('Hello World..!')">Click Me!</button>
</body>
</html>
Output
Click Me!
Syntax
<form action="action-page.php" method="get">
<form action="action-page.php" method="post">
Data Pass Limited amount of data can be sent Large amount of data can be sent
because data is sent in header. because data is sent in body.
Security Get request is not secured because Post request is secured because data
data is data sent is part of the URL, is not exposed in URL bar and
and this data saved in browser parameters are not stored in browser
history and server logs in plaintext. history or in web server logs.
Bookmarked Request can be bookmarked and Request can not be bookmarked and
cached. cached.
Usability GET method should not be suitable POST is good for when you are
when you are sending sensitive data sending sensitive data because your
like user id or Passwords. data are sended in encrypted form.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Name Attribute </title>
</head>
<body>
<form action="action-page.php">
First name:
<input type="text" value="John">
Last name:
<input type="text" name="lastname" value="Snow">
<input type="submit" value="Submit">
</form>
</body>
</html>
Output
John Snow Submit
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Fieldset and Legend Attributes </title>
</head>
<body>
<form action="action-page.php">
<fieldset>
<legend>Personal information:</legend>
First name:
<input type="text" name="firstname" value="John">
Last name:
<input type="text" name="lastname" value="Snow">
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
Output
John Snow Submit
Personal information:First name: Last name:
The different types of HTML input type are specified by its ‘type’ attribute, each input type
has a different ‘type’ attribute value associated with it. Let’s see the common values of ‘type’
attribute:
Type Description
Output
Submit
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Input Type Password </title>
</head>
<body>
<form action="#">
User name:
<input type="text" name="userid">
User password:
<input type="password" name="psw">
</form>
</body>
</html>
Output
User name: User password:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Input Type Submit </title>
</head>
<body>
<form action="action-page.php">
First name:
<input type="text" name="firstname" value="John">
Last name:
<input type="text" name="lastname" value="Snow">
<input type="submit" value="Submit">
</form>
</body>
</html>
Output
John Snow Submit
First name: Last name:
Output
John Snow Submit Reset
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Input Type Radio Button </title>
</head>
<body>
<form action="action-page.php">
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="radio" name="gender" value="other"> Other<br><br>
<input type="submit">
</form>
</body>
</html>
Output
Male
Female
Other
Submit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Input Type Checkbox </title>
</head>
<body>
<form action="action-page.php">
<input type="checkbox" name="vehicle1" value="Bike">Samsung
<input type="checkbox" name="vehicle2" value="Car">Google Pixel>
<input type="submit">
</form>
</body>
</html>
Output
Samsung Google Pixel
Submit
Output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Input Type Number </title>
</head>
<body>
<form action="action-page.php">
Quantity (between 1 and 10):
<input type="number" name="quantity" min="1" max="10">
<input type="submit">
</form>
</body>
</html>
Output
Submit
Quantity (between 1 and 10):
readonly It specifies that an input field is read only that cannot be changed.
Email Fields
The value "email" is used for creating an input field for email address. This HTML input
type is specifically used to validate the email address entered by the user. It uses the standard
email address format and the user violates it then it shows error. Syntax: <input
type=email>
Number Fields
The value "number" will create an input field to enter only numbers, if you enter alphabets or
symbols or anything other than numbers, it will show an error, however decimal points
numbers are allowed. Syntax:<input type=number>
Search Fields
It is used to create a search box. You can even add placeholder in the search box by using the
‘placeholder’ attribute. Syntax: <input type="search">
URL Fields
Specifically used to enter a URL. Syntax: <input type="url">
Number Fields
This HTML input type provides controls to enter numbers. It has small buttons on the right
side to increase or decrease the value of the number. In your smartphones this input type
automatically opens the numeric keyboard during entering the data. Syntax:<input
type="number">
Range Fields
It creates a slider to select a value in within a range of two values. Syntax: <input
type="range" min="0" max="10">
Date Fields
This type is used to create an input area to enter date. You can manually enter the date or can
select value from a graphical calendar. Syntax:<input type="date">
Month Fields
It only provide options of Month and year. Syntax:<input type="month">
Week Fields
Allows you to pick the week and year. Syntax:<input type="week">
Time Fields
Allows you to enter time of the day. It can be entered manually or by the help of a digital
clock format. Syntax:<input type="time">
Datetime-local Fields
Enter Date and time together in a single input field. Syntax:<input type="datetime-local">
Color Fields
If you want to enter any RGB color information on the database then use this input
type. Syntax:<input type="color">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Value Attribute </title>
</head>
<body>
<form action="#">
First name:
<input type="text" name="firstname" value="John">
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
Output
John
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Readonly Attribute </title>
</head>
<body>
<form action="#">
First name:
<input type="text" name="firstname" value ="John" readonly>
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
Output
John
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Disabled Attribute </title>
</head>
<body>
<form action="#">
First name:
<input type="text" name="firstname" value ="John" disabled>
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
Output
John
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form Size Attribute </title>
</head>
<body>
<form action="#">
First name:
<input type="text" name="firstname" value="John" size="30">
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
Output
John
First name: Last name:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Form maxlength Attribute </title>
</head>
<body>
<form action="#">
First name:
<input type="text" name="firstname" maxlength="10">
Last name:
<input type="text" name="lastname">
</form>
</body>
</html>
Output
First name: Last name:
Note : The maxlength attribute, will not accept more than the allowed number of characters in input
field.
autofocus It make sure that the input field automatically get focused when the
page loads.
formaction It specifies the URL of a file where the form data will get transferred
and processed after submitting.
formenctype It specifies how the form data should be encoded when submitted.
formmethod It defines the HTTP method for sending form-data to the action URL.
Attribute New Description
height & width It specifies the height and width of an <input> element.
min and max It specifies the minimum and maximum values for an <input>
element.
multiple It allows the user to enter more than one value in the <input>
element.
placeholder It gives a hint about the value to be entered in the <input> element.
required It specifies that an input field must be filled out before submitting the
form.
HTML Title
HTML Title Tag
HTML <title> tag is required in all HTML documents and it defines the title of the page.
The title tag is also one of the ranking factor for search engines. When you write search
engine friendly titles, search engines give you better rankings in their search results.
Page titles are meant to be accurate, concise page's content. Your title should be below 60
character because Google search engine displays only first 50–60 characters of a title tag.
The <title> tag is used inside the <head> tag. It is a paired tag and the page title is written
between opening and closing tags.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
The title attribute can be used with several HTML tags. The syntax is given below in the
example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Title Attribute </title>
</head>
<body>
<p><abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>
<p title="Free Web tutorials">CodeRepublics.com</p>
</body>
</html>
Output
WHO was founded in 1948.
CodeRepublics.com
By default, without any specific attribute, content within the <marquee> tag will scroll from
right to left. The marquee tag has been deprecated in HTML5 and should no longer be used.
You should use CSS instead to create a similar scrolling effect. We can now use the
following CSS3 properties like marquee-play-count, marquee-style, overflow-style, marquee-
direction and marquee-speed.
Look at the example below, in which the default scrolling effect is running.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Marquee Tag </title>
</head>
<body>
<marquee> This is an example of HTML marquee. </marquee>
</body>
</html>
Output
Marquee Scroll Property
Marquee Scroll is a default property. During scroll, the text floats from right to left and
restarts from the right side of the marquee when it reaches to the end on the left side of the
screen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Scroll Attribute </title>
</head>
<body>
<marquee width="100%" behavior="scroll" direction="up">
This is an example of a scroll marquee Up Side Direction...
</marquee>
</body>
</html>
Output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Marquee Slide Attribute </title>
</head>
<body>
<marquee width="100%" behavior="slide">
This is an example of a slide marquee...
</marquee>
</body>
</html>
Output
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> HTML Marquee Alternate Attribute </title>
</head>
<body>
<marquee width="100%" behavior="alternate">
This is an example of a alternate marquee...
</marquee>
</body>
</html>
Output
Output
behavior The behavior of how the text scrolls... It sets the behavior of the marquee to
one of the three different types: scroll, slide, and alternate.
scrolldelay The delay in milliseconds between scrolling. The default value is 85 if the
Attribute Description
scrollamount The amount of scrolling (in pixels) for each interval. The default value is 6 if
the scrollamount is not specified.
loop It defines the number of times that the text will scroll. The default value is -1
which means that the marquee will loop continuously.
Methods Description
onbounce The onbounce event fires when the behavior attribute is set to alternate and the
text has reached the edge of the marquee.
onfinish The onfinish event fires when the loop attribute is set to a value higher than 0
and the marquee has finished looping the specified number of times.
<body>
<code>Contents... </code>
</body>
Output
Emphasized text
Strong text
A piece of computer code
Sample output from a computer program
Keyboard input
Variable
Attributes
Only the Global Attributes can be apply to the <code> tag. There are no such attributes that
are specific to this html code tag.
Things you need to konw about before using code tag in html web page or doument
The code tag in html supports almost all popular web browsers like Google Chrome,
Android, Edge, Firefox, Opear, Safari and more..