HTML basics

This tutorial represents all of the HTML tags that are mostly used to make a web page. The following topics enable you to make a web page and they cover most of the material of HTML.

HTML syntax

Every language has its own syntax. The syntax is an arrangement of words according to the rules of language. Similarly, there is also basic syntax to write HTML.


<!DOCTYPE html>


  <p>This is a new paragraph.</p>

Try </>

The basic syntax of HTML has been given above. Its structure is very simple and resembles a human being. Like a human being, it consists of a head (serves as the brain of the page) and body (serves as the visible portion of a page).

<!DOCTYPE> represents the type of document. It means that this document is of HTML.


An element usually consists of opening and closing tags. For example, <h1> is opening and </h1> is closing tag.


<code>This is code element.</code>
<p>This is a paragraph element.</p>

Try </>


There are three kind of tags. Opening, closing and self-closing tags.Opening and closing tags alway come in pair(<p>-</p>).

And self-closing tag is always single with the optional forward slash after tag name. (<br/>)


<h1>Heading1</h1> <!--opening and closing tags -->
<br/> <!--Self closing tag -->

Try </>


An attribute provides the additional information about the tag and make it more useable. For example, title, contenteditable, readonly, width, height etc.


<p title="new paragraph">This is a paragraph</p>
<p contenteditable> content is editable.</p>

Try </>

The attribute is always written in opening tag with the name-value pair.


<h1> to <h6> tags are used for headings. The purpose of these headings is to represent the topic. The headings are ranked from h1 to h6.


<h1>The heading1</h1>
<h2>The heading2</h2>
<h3>Third level heading</h3>
<h4>The heading4</h4>
<h5>The heading5</h5>
<h6>Least important heading</h6>

Try </>

<p> tag represents the paragraph.


<img> element adds an image on the page. The 'src' attribute contains the address of the image.


<img src="directory/name of image" alt="alternate text">
<img src="/images/codingb-32x32.png" alt="image logo">

Try </>

width and height attributes set the dimension of the image.


The anchor link (<a>) connects the current document to the other pages or resources.


<a href="address of the external" target="_blank">anchor text</a>
<a href="" target="_blank">web4college</a>

Try </>

href attribute contains the address of external page or resource.

target="_blank" means the link opens in new window.


These lists may be used , to wirte components in an unordered form and represent the term-definition pairs.


Ordered list

  1. Mix both solutions
  2. Stir them well.
  3. Add a few drops of the sulphuric acid.

Unordered list

  • Sulphuric Acid
  • Temperature
  • Solution1

Definition lists

The string is the group of characters in the double quotation marks.
The operators perform operations on operands and do calculations.
Try </>

Unordered list

Unordered lists are used where the order of items is not necessary. For example, it may be used to write the components of a recipe.

Ordered list

Ordered lists are used where order of items is necessary. For example, it is used to instruct someone for a specific task (recipe).

Definition list

It is used for the terms and their definitions.


Tables are used to represent the data in the form of columns or rows. The basic data cells contain the data.


Name Salary
john $20,000
david $30,000
marry $40,000
Try </>

tr represents table row. td is for table data. th is an abbreviation of table head.

Text formatting

There are many elements that format the text.


bold text

italic text

underline text

marked text


Try </>

<b>, <i>, <strong>, <em>, <u>, <mark>, <del>, <insert>, <sub>, <sup>, <var> elements format the text.


Comment is used to provide the information why this code has been written especially in complex coding. Comments are not visible in the web page. It may be a single line or multi-line comment.


<!---This is the syntax to write a comment ---->
<!---This is multi-line 
comment ---->

Try </>


The colors may be represented in decimal notation or hexadecimal notation. The named colors may also be used.


color:green; <!--- name color -->
color:rgb(255,0,0); <!--- decimal notation -->
color:#ff0000; <!--- hexadecimal notation --->

Try </>


Head element contains the meta data, the addresses of external resources such as <link> tag to import css file and <script> tag to import script file.


<title>title of page</title>
<link href="test.css" rel="stylesheet"> <!--- imports external css file --->
<base href=""> <!--- The default url of the page --->
<meta name="keywords" value="html basics, html codes, html page">

Try </>

Click on the head to learn more.


<video> tag adds a video on the page. We write the address of the video in the 'src' attribute of video tag.


Try </>

controls attribute adds controls on the video.


<audio> tag adds an audio on the page. We write the address of audio in the 'src' attribute.


Try </>


HTML iframe is used to browse the other HTML files or other browsing content in a specified frame. It is an inline element.


 <iframe src="files/value.html" ></iframe>
iframe can embed website
 <iframe src="" ></iframe>

Try </>


HTML form is used to collect the data from the user. It consists of normal content, other input controls (text, number, buttons, checkbox etc.) and context menus (select, option, optgroup etc).


First name:

Last name:

Male   Female

Calculus-I:   Calculus-II:

Try </>

Was this article helpful?