Loading...
Website Development Tutorial

How to Develop a Website – Part 1

In this tutorial, I will teach you how to develop a website from scratch step by step. I will start from basics and gradually move to advance level. In order to develop a website, you should know three technologies – HTML, CSS and JavaScript. HTML is used to develop web pages, CSS is used to design and beautify web pages and JavaScript is used to make the web pages dynamic. Let’s start with HTML.

Introduction:

HyperText Markup Language (HTML) is the markup or tag based language that is used to create web pages or html documents. HTML comes with couple of tags using which we can define the structure of the document and logically organize the content in it, for example defining headings, sections, paragraphs and data tables, or embedding images and videos in the page. Collection of such inter-related web pages is known as Website.

The standard structure or markup of a basic web page is given below –

<!DOCTYPE html> 
<html>
  <head>
    <title>First Web Page</title>
  </head>
  <body>
    <p> Hello there! </p>
  </body>
</html>

Here the words enclosed with<> brackets (like <html>, <head>, <body> etc.) are known as tags.

In HTML we have two types of tags, the first type of tags come in pair – opening and companion closing tags. These tags are called Paired Tag or Container Tag. A forward slash (/) is added in the beginning of a tag to close it. For example, <html> is opening tag and </html> is the companion closing tag. Almost 99% of tags in HTML are paired.

The second type of tags do not have the companion closing tag. Such tags are known as Singular Tag or Stand-alone Tag or Empty tag. Some of the Singular tags are listed below-

TagNameDescription
<hr>Horizontal RuleInsert a horizontal line
<br>Line BreakInsert a line break
<img>ImageInsert Image
<input>Form InputInsert form input
<!DOCTYPE>Document Type Specify the html version used

There are close to 100 tags in HTML, but we end up using only few of them. In the last 12 years, being a Web Developer, I might have used hardly 30-40% of the tags and it is perfectly normal. Some of the most commonly used tags while building web pages are given below –

TagNameDescription
<!– –>Comment This tag is used to apply comment in an HTML document
<!DOCTYPE> Document Type This tag is used to specify the version of HTML
<html>HtmlRoot element of html document
<head>HeadContains meta data of the document
<title>TitleContains page title of the document
<body>BodyContains document’s main content
<div>DivisionA section in the document
<p>ParagraphDefines a paragraph
<span>SpanA smaller section
<table>TableDefines a table
<ol>Ordered ListDefines an ordered list
<ul>Unordered List Defines an unordered list
<li>List Item Defines an item in list
<form>FormDefines a html form to capture user inputs
<input>HTML Form InputHtml for controls
<select>Dropdown ListDefines a dropdown list
<option>Dropdown List OptionDefines a dropdown list option
<b>, <strong>BoldMakes text bolder
<i>ItalicMakes text italic
<u>UnderlineUnderline text
<sup>Super ScriptCreate superscripted text (appears above)
<sub>Sub ScriptCreate subscripted text (appears below)
<h1> to <h6>HeaderDefine page headers
<a>AnchorCreate a hyper link
<link>LinkLink external style sheet (CSS) file
<script>Link JavaScriptLink external JavaScript file

<html> is the root tag of a web page, and it contains<head> and <body> tags. The <head> tag contains information about the web page and other meta data. The <title> tag comes under <head> tag and it contains the title of the web page. Any thing you write inside the title tag will appear in the browser tab when you view the page.

Web Page Title

The title tag may also contain many more other tags which I will discuss as we progress. The body tag contains the actual content of the page, anything you write inside body tag will be visible in the browser.

Elements and Attributes:

In html, a tag along with it’s content is known as element. For example, in the following code, p is an element.

// An element
<p class="text"> This is a paragraph </p>
HTML Tag, Attribute, Value and Element

HTML attributes provide additional information about HTML elements. It is not mandatory that every element should have some attribute. In the above example, the element has an attribute class with value text, which is nothing but a CSS class that defines the style of the element. At this point you might not be familiar with CSS. While learning CSS, you will understand the use of this attribute. An element may have multiple attributes as well. Some of the commonly used attributes are – id, class, style and title.

The are some tag specific attributes which can not be used in any other element. For example, src and alt can be used with <img> tag only. Similarly, href and target can be used only with <a> tag.

// Only image (img) element may have src, alt attributes
<img src = "images/some-image.png" alt="This text will appear if the image is not found."/>

// Only anchor (a) element may have href and target attributes 
 <a href = "www.facebook.com" target="_blank">Go to Facebook</a>

Getting Started:

We have sufficient theoretical knowledge now. Let’s get into coding now!

1. Create a folder anywhere in your computer and give a name of your choice, let’s say mywebsite. Open any text editor/notepad and write the html code given below.

<!DOCTYPE html> 
<html>
  <head>
    <title>First Web Page</title>
  </head>
  <body>
     <h1> Hello world! </h1>
     <p> I am learning HTML </p>
  </body>
</html>

2. Name the file index.html and save it in the folder you created. Note that html files should be saved with .html extension. You can also save the file with just .htm extension, but I will not recommend it. Let’s code clean.

Technically, index means first page or home page of your website. Although, it is not mandatory, it is good practice to name it index. It also helps browser to understand which page it should display if there are multiple pages in the folder once we deploy our website in server. You will understand this later.

Save Html File

3. Open the file in a browser.

Open Html File

This is how the page will appear in the browser –

First Web Page

That’s all. You have successfully developed your first web page.

As you can see, content written inside body tag is only visible in the browser. Browser does not display the html tags, it just interpret the file and displays the content in the same order we wanted to display. The page seems very plain and null. To style & make it look beautiful, we will have to write CSS code.

Tips: For better coding experience, you can use notepad++, it has some more features. You can download it from here.

Now, lets add some more content in the page and leverage other html tags.

<!DOCTYPE html> 
<html>
  <head>
    <title>First Web Page</title>
  </head>
  <body>
	<h1> Hello world! </h1>
	<p> I am <b>learning</b> HTML </p>
	<p> This text will appear <i>italic</i> </p>

        <p> This is my 1<sup>st</sup> web page</p>
	<p> Scientific name of water is H<sub>2</sub>O <p>

	<h2> Unordered List Example </h2>
	<ul>
	  <li>HTML</li>
	  <li> CSS </li>
	  <li> JavaScript</li>
	</ul>

	<hr>

	<h2> Ordered List Example </h2>
	<ol>
	  <li>HTML</li>
	  <li> CSS </li>
	  <li> JavaScript</li>
	</ol>

	<hr>

	<div> 
	  This is a division. Division can contain all other tags.
	  <p> I am a paragraph inside div.</p>
	  <span> I am a span1 </span>
	  <span> I am a span2 </span>
	</div>	
  </body>
</html>

The output of the above code would be something like this-

Isn’t it easy? Okay. Now here is an exercise for you. Create your resume in html. Here are some hints:

  • Use <div> tags to separate each section.
  • Add description in <p> tags.
  • Use header tags <h1>, <h2> etc. for section’s titles.
  • Use <ol> and <ul> to list your skills and educational qualifications.
  • Use <hr> to separate sections.
  • Use <b>, <i>, <u> tags to highlight text.

Good luck.

How to Develop a Website: Part 2

Share this article with your friends
Leave a Reply

Your email address will not be published. Required fields are marked *