Introduction to HTML CSC 221
Introduction to HTML CSC 221
A webpage is a page containing information about any things in web. To develop such web pages, a markup
language is used called HTML. HTML stands for Hyper Text Markup Language which is used to develop any kinds
of web pages. It was developed by Tim Berners Lee in 1990 A.D.
Creating HTML page:
Creating an HTML document is easy. To begin coding HTML you need only two things: a simple-text editor and a
web browser.
Here are some examples of text editors that will enable you to create html page
Notepad, Notepad 2, Notepad ++, Pspad, Visual Studio Code, Microsoft FrontPage, Macromedia Dreamweaver,
Netscape Composer, Komodo e.t.c. Notepad is the most basic of simple-text editors and you will probably code a
fair amount of HTML with it.
Click Save.
<!doctype.html>
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
You have basic HTML document now, to see some result put the following code in title and body tags.
<!doctype.html>
<html>
<head>
1
<title>Department of Computer Science AACOE, Argungu</title>
</head>
<body>
<h1>ADAMU AUGIE COLLEGE OF EDUCATION, ARGUNGU, KEBBI STATE</h1>
<p>Department of Computer Science AACOE, Argungu Result Management System</p>
</body>
</html>
Now you have created one HTML page and you can use a Web Browser to open this HTML file to see the result.
Hope you understood that Web Pages are nothing but they are simple HTML files with some content which can
be rendered using Web Browsers.
Here <html>, <head>, ...<p>, <h1> etc. are called HTML tags. HTML tags are building blocks of an HTML
document and we will learn the entire HTML tags in subsequent chapters.
Tags in HTML
HTML Tag
All the codes used in HTML are called Tags. Tags are enclosed within angular brackets. There are two types of
tags:-
1. Container Tag:- The tags that needs to be closed are called container tags. Eg <html>…</html>,
<body>…..</body> etc.
2. Empty Tags:- The tags that doesn’t need to be closed are called empty tags. Eg:- <br>,<img> and
<h>.
Attributes
Attributes are the properties of tags. The attributes contain values inside tags. For e.g, <p align=”center”>I am
an student</p>. Here, ‘align’ is an attribute and ‘center’ is a value.
2
18. <img>:- Inserts an image. Its attributes are src, width, height, align, border, alt. Eg:- <img
src=”d:\photos\aa.jpg” height=”20%” width=”30%”>
Table Tags
1. <table>…</table>:- Defines beginning and ending of table. Its attributes are border, bgcolor, width
etc.
2. <tr>…</tr>:- Defines beginning and ending of table row. Its attributes are align, bgcolor etc.
3. <td>…</td>:- Defines beginning and ending of table cell. Its attributes are bgcolor, align, colspan,
rowspan etc.
4. <th>…</th>:- Defines table heading.
Form tags
1. <form>…</form>:- Defines beginning and ending of form
2. <input>:- Defines type of form. Its attributes are (a) Type:- It defines type of form and its values are
text, password, radio, checkbox, submit and reset. (b) Name:- It defines the name of form.
3. <select>…</select>:- It gives the list box to select items. The items should be inside
<option>…</option> tag.
4. <textarea>…</textarea>:- It is used to insert the large texts. Its attributes are rows and cols.
An HTML document starts and ends with <html> and < /html> tags.
These tags tell the browser that the entire document is composed in HTML. Inside these two tags, the document
is split into two sections:
The <head>...</head> elements, which contain information about the document such as title of the document,
author of the document etc. Information inside this tag does not display outside.
The <body>...</body> elements, which contain the real content of the document that you see on your screen.
HTML language is a markup language and we use many tags to markup text. In the above example you have
seen <html>, <body> etc. are called HTML tags or HTML elements.
Every tag consists of a tag name, sometimes followed by an optional list of tag attributes, all placed between
opening and closing brackets (< and >). The simplest tag is nothing more than a name appropriately enclosed in
brackets, such as <head> and <i>. More complicated tags contain one or more attributes, which specify or
modify the behavior of the tag.
According to the HTML standard, tag and attribute names are not case-sensitive. There's no difference in effect
between <head>, <Head>, <HEAD>, or even <Head>; they are all equivalent.
What is Next?
Next you will see basic HTML tags in more detail and you will have understanding on HTML tags attributes also.
The basic structure for all HTML documents is simple and should include the following minimum elements or
tags:
Now we will explain each of these tags one by one. In this tutorial you will find the terms element and tag are
used interchangeably.
3
The <html> Element:
The <html> element is the containing element for the whole HTML document. Each HTML document should have
one <html> and each document should end with a closing </html> tag.
As such, start and end HTML tags enclose all the other HTML tags you use to describe the Web page.
The <link> element is used to link an external CSS file named "styles.css" located in the same directory as your
HTML file.
The <script> element is used to include an external JavaScript file named "script.js," which should also be
located in the same directory as your HTML file.
Here is an example of how to use a head tag.
<head>
<title>HTML Basic tags</title>
<script src="script.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</head>
Therefore it is important to use a title that really describes the content of your site. The <title> element should
contain only the text for the title and it may not contain any other elements.
Example:
Here is an example of how to use a title tag.
<head>
<title>HTML Basic tags</title>
</head>
4
The <body> Element:
The <body> element appears after the <head> element and contains the part
of the Web page that you actually see in the main browser window, which is sometimes referred to as body
content.
A <body> element may contain anything from a couple of paragraphs under a heading to more complicated
layouts containing forms and tables.
Most of what you will be learning in this and the following five chapters will be written between the opening
<body> tag and closing </body> tag.
Example:
Here is an example of how to use a body tag.
<body>
<p>This is a paragraph tag.</p>
</body>
Create Headings
The <hn> Elements:
Any document starts with a heading. You use different sizes for your headings. HTML also has six levels of
headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and <h6>. While displaying any heading,
browser adds one line before and after that heading.
Example:
<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>
This is heading 1
This is heading 2
This is heading 3
This is heading 4
5
This is heading 5
This is heading 6
This is justified. This works when you have multiple lines in your paragraph and you want to justify all the lines
so that they can look more nice.
Example:
6
<center><p>This is in the center.</p></center>
No breaking Spaces:
Horizontal Rules - The <hr /> Element
Horizontal rules are used to visually break up sections of a document. The <hr> tag creates a line from the
current position in the document to the right margin and breaks the line accordingly.
For example, you may want to give a line between two paragraphs as follows:
7
Superscript Text - The <sup> Element:
The content of a <sup> element is written in superscript; the font size used is the same size as the characters
surrounding it but is displayed half a character’s height above the other characters.
Font Size:
You can set the size of your font with size attribute. The range of accepted values is from 1(smallest) to
7(largest). The default size of a font is 3.
Example:
8
<font size="1">Font size="1"</font>
<font size="2">Font size="2"</font>
<font size="3">Font size="3"</font>
<font size="4">Font size="4"</font>
<font size="5">Font size="5"</font>
<font size="6">Font size="6"</font>
<font size="7">Font size="7"</font>
Font size="1"
Font size="2"
Font size="3"
Font size="4"
Font size="5"
Font size="6"
Font size="7"
Font Face:
You can set any font you like using face attribute but be aware that if the user viewing the page doesn't have the
font installed, they will not be able to see it. Instead, they will default to Times New Roman of your font with size
attribute. See below few examples on using different font face.
Example:
Example:
<font face="Tahoma">
<font face="Comic Sans”>
9
When your page is loaded, their browser will display the first font face that it has available. If none of your
selections are installed....then it will display the default font face Times New Roman.
Font Color:
You can set any font color you like using color attribute. You can specify the color that you want by either the
color name or hexadecimal code for that color.
Example:
</marquee>
Attributes:
A HTML marquee can have following attributes:
➢ Width: how wide the marquee is. This will have a value like 10 or 20%etc.
➢ Height: how tall the marquee is. This will have a value like 10 or 20% etc.
➢ Direction: which direction the marquee should scroll. This will have value
➢ Either up, down, left or right.
➢ Behavior: what type of scrolling. This will have value scroll, slid and alternate.
➢ Scroll delay: how long to delay between each jump. This will have a value like 10 etc.
➢ Scroll amount: how far to jump. This will have a value like 10 etc.
➢ Loop: how many times to loop. The default value is INFINITE, which
➢ Means that the marquee loops endlessly.
➢ Bicolor: background color. This will have any color name or color hex value.
➢ Hspace: horizontal space around the marquee. This will have a value like 10 or 20%etc.
➢ Vspace: vertical space around the marquee. This will have a value like 10 or 20%etc.
Examples:
Here are few examples to demonstrate the usage of marquee tag.
10
<marquee width="50%">This example will take only 50% width</marquee>
HTML TABLE
Tables are very useful to arrange in HTML and they are used very frequently by almost all web developers.
Tables are just like spreadsheets and they are made up of rows and columns.
You will create a table in HTML/XHTML by using <table> tag. Inside <table> element the table is written out
row by row. A row is contained inside a <tr> tag. Which stands for table row. And each cell is then written inside
the row Element using a <td> tag. which stands for table data.
Example:
<table border="1">
<tr>
<td>Java</td>
<td>Php</td>
</tr>
<tr>
<td>Python</td>
<td>Visual Basic</td>
</tr>
</table>
Java Php
11
Python Visual Basic
In the above example border is an attribute of <table> and it will put border across all the cells. If you do not
need a border then you can use border="0".
The border attribute and other attributes also mention din this session are deprecated and they have been
replaced by CSS. So, it is recommended to use CSS instead of using any attribute directly.
<table border="1">
<tr>
<th>Course Title</th>
<th>Course Code </th>
</tr>
<tr>
<td>Introduction to Computer</td>
<td>5000</td>
</tr>
<tr>
<td> Operating System </td>
<td>COM 202</td>
</tr>
</table>
This will produce following result. You can see its making heading as a bold one:
Each cell must, however, have either a <td> or a <th> element in order for the table to display correctly even if
that element is empty.
12
</tr>
<tr>
<td> Introduction to Computer </td>
<td> COM 201</td>
</tr>
<tr>
<td> Operating System </td>
<td> COM 202</td>
</tr>
</table>
<table border="1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">HTML</td>
<td>PHP</td><td>XHTML</td></tr>
<tr><td>ASP</td><td>C+</td></tr>
<tr><td colspan="3"> C++ </td></tr>
</table>
Tables Backgrounds
You can set table background using of the following two ways:
➢ Using bgcolor attribute - You can set background color for whole table or just for one cell.
13
➢ Using background attribute - You can set background image for whole table or just for one cell.
14
Table height and width:
You can set a table width and height using width and height attributes. You can specify table width or height in
terms of integer value or in terms of percentage of available screen area. Following is the example:
HTML PHP
JavaScript XHTML
The typical browser formats the contents of an ordered list just like an Unordered list, except that the items are
numbered instead of bulleted. The numbering starts at one and is incremented by one for each successive
ordered list element tagged with <li> This list is created by using <ol> tag. Each item in the list is marked with a
number.
<center>
<h2> Programming Languages </h2>
</center>
<ol>
<li> C</li>
<li> C#</li>
<li> C++</li>
<li> Java</li>
</ol>
Programming Languages
1. C
2. C#
3. C++
15
4. Java
HTML COLOR
You can specify direct a color name to set text or background color. There are 16 basic color names that will
validate with an HTML validator but there are over 200 different color names supported by browsers.
Here is the list of Standard 16 Colors names and it is recommended to use them.
HTML FORMS
HTML Forms - Text Input Controls: There are actually three types of text input used on forms:
➢ Single-line text input controls: Used for items that require only one line of user input, such as search boxes or
names. They are created using the <input> element.
➢ Password input controls: Single-line text input that mask the characters a user enters.
➢ Multi-line text input controls: Used when the user is required to give details that may be longer than a single
sentence. Multi-line input controls are created with the <textarea> element.
Here is a basic example of a single-line text input used to take first name and last name:
<form>
First name:
<input type="text" name="first_name" />
<br>
Last name:
<input type="text" name="last_name" />
<input type="submit" value="submit" />
</form>
16
This will produce the result below:
This is also a form of single-line text input controls are created using an <input> element whose type attribute
has a value of password.
Here is a basic example of a single-line password input used to take user password:
<form>
Login :
<input type="text" name="login" />
<br>
Password:
<input type="text" name="password" />
<br>
<input type="submit" value="submit" />
</form>
You can use <button> element to create various buttons. Here is the syntax:
<form>
<button type="submit">Submit</button>
<br /><br />
<button type="reset"> Reset </button>
<button type="button"> Button </button>
</form>
17
HTML Forms - Checkboxes Control:
Checkboxes are used when more than one option is required to be selected. They are created using <input> tag
as shown below.
<form>
<input type="checkbox" name="maths" value="on"> Maths
<input type="checkbox" name="physics" value="on"> Physics
<input type="submit" value="Select Subject" />
</form>
Radio Buttons are used when only one option is required to be selected. They are created using <input> tag as
shown below:
Here is example HTML code for a form with two radio button:
<form>
<input type="radio" name="subject" value="maths" /> Maths
<input type="radio" name="subject" value="physics" /> Physics
18
<input type="submit" value="Select Subject" />
</form>
Text area are Used when the user is required to give details that may be longer than a single sentence. Multi-line
input controls are created with the <textarea> element.
<form>
<textarea rows="2" name="S1" cols="20"></textarea>
</form>
Drop down box are Used when the user is required to select data from the list. Drop down box controls are
created with the <select> element.
19
HTML COLOR HEX CODE
20
Programming Concepts and Logics
Programming Languages
We know that the communication between human being require their languages which is called
natural language like English, Nepali, Hindi etc. Like this, when we use computers, we need to communicate with
computers that means we have to give instructions to computer. The language that is used to communicate with
computer or to give instructions to computer is called programming language.
Types of Programming language
1. Machine Level Language
Machine level language is the first programming language that is used to develop programs in
computer. It is called machine level because it is directly understood by computer or CPU. So, it is the
language of CPU that contains only 0’s and 1’s. To write programs using MLL, a programmer should have
complete knowledge about internal structure of machine. Since it is directly understood by CPU, it doesn’t
require any translating software.
21
not understood by CPU, it needs a language translator called Assembler which translates program written in
Assembly language to machine level language.
22
1. Syntax error:- Syntax is the rule of writing codes used in the program in structured manner. The error
which occurs when the instruction of program does not match the structural rule of programming
language is called syntax error. The syntax error is easy to correct because it can be detected by compiler
or interpreter.
2. Semantic error:- The error which causes the wrong output due to the wrong calculation or wrong input
of data in the programming is called semantic error. It is not detected by compiler or interpreter, to
detect semantic error, the programmer has to look over the program and check where the mistake is.
3. Run-time error:- The error which occurs during the execution or run-time of a program is called run-
time error. Such type of error occurs when the computer is asked to divide by zero or a variable is
assigned beyond its capacity. The run-time error causes termination of a program.
3. Pseudo code
The meaning of ‘Pseudo’ is false or fake. So the pseudo code means false or fake code. We write
algorithm and flowchart using the mixing of English language and programming language. The codes used to
write algorithm and flowchart looks like codes of programming language but it is not syntactically correct, so
it is called pseudo code. For example:-
Pseudo code to add two numbers:-
Enter a and b
Calculate s=a+b
print s
Program design tools
1. Algorithm
Algorithm is the stepwise description of any program. It is written before writing any program. It
helps to solve different problems that come in the program because it gives step by step definition of a
program It is written using mixing of English language and programming language. Example:-
1. Start
2. Enter a and b
3. Calculate s= a+b
4. Print s
5. End
2. Flowchart
A flowchart is a graphical representation of any program. It gives a clear view of any program by
representing a program in graphical manner. It is written after preparing algorithm. The flowchart consists of
different symbols and each symbol has specific meaning. So to draw any type of flowchart, we must
understand each symbol correctly. Following are the symbols that are generally used in flowchart:-
23