Full Lecture Note On HTML by Fraol
Full Lecture Note On HTML by Fraol
Chapter 2
Basics of HTML
By Firaol K. (Msc.)
April 2025
Basics of HTML
HTML stands for Hyper Text Markup Language. An HTML file is a text file
containing markup tags.
The markup tags tell the Web browser how to display the page. An HTML file must
have an ‘htm’ or ‘html’ file extension. An HTML file can be created using a simple
text editor. The rule-making body of the Web is World Wide Web Consortium
(W3C). W3C puts together specifications for Web standards. The most essential
Web standards are HTML, CSS and XML. The latest HTML standard is XHTML 1.0.
1. Start Notepad.
2. Type in the following text
<html>
<head>
<title>Title of page</title>
</head>
<body>
This is a very basic webpage. <b>This text will be displayed in bold</b>
</body>
</html>
Example Explained:
The first tag in your HTML document is <html>. This tag tells your browser that this is
the start of an HTML document. The last tag in your document is </html>. This tag tells
your browser that this is the end of the HTML document.
The text between the <head> tag and the </head> tag is header information. Header
information is not displayed in the browser window.
The text between the <title> tags is the title of your document. The title is displayed in
your browser's caption.
The text between the <body> tags is the text that will be displayed in your browser.
The text between the <b> and </b> tags will be displayed in a bold font.
When you save an HTML file, you can use either the .htm or the .html extension. We
have used .html in our example.
HTML Tags
We have just said that HTML tags are not case sensitive: <B> means the same as <b>. It
is recommended to always use because
If you want to prepare yourself for the next generations of HTML, you should start
using lowercase tags. The World Wide Web Consortium recommends lowercase
tags in their HTML 4 recommendation, and XHTML (the next generation HTML)
demands lowercase tags.
Tags can have attributes. Attributes can provide additional information about the HTML
elements on your page.
This tag defines the body element of your HTML page: <body>. With an added bgcolor
attribute, you can tell the browser that the background color of your page should be red,
like this: <body bgcolor="red">.
Attribute values should always be enclosed in quotes. Double style quotes are the most
common, but single style quotes are also allowed. In some rare situations, like when the
attribute value itself contains quotes, it is necessary to use single quotes:
Headings
Headings are defined with the <h1> to <h6> tags. <h1> defines the largest heading.
<h6> defines the smallest heading.
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
<h4>This is a heading</h4>
<h5>This is a heading</h5>
<h6>This is a heading</h6>
HTML automatically adds an extra blank line before and after a heading.
Paragraphs
<p>This is a paragraph</p>
HTML automatically adds an extra blank line before and after a paragraph.
Line Breaks
The <br> tag is used when you want to end a line, but don't want to start a new
paragraph. The <br> tag forces a line break wherever you place it.
Comments in HTML
The comment tag is used to insert a comment in the HTML source code. A comment will
be ignored by the browser. You can use comments to explain your code, which can help
you when you edit the source code at a later date.
Note: that you need an exclamation point after the opening bracket, but not before the
closing bracket.
Tag Description
HTML uses the <a> (anchor) tag to create a link to another document.
An anchor can point to any resource on the Web: an HTML page, an image, a sound file,
a movie, etc.
The <a> tag is used to create an anchor to link, the href attribute is used to address the
document to link to, and the words between the open and close of the anchor tag will be
displayed as a hyperlink.
With the target attribute, you can define where the linked document will be opened.
The line below will open the document in a new browser window:
The name attribute is used to create a named anchor. When using named anchors we
can create links that can jump directly into a specific section on a page, instead of letting
the user scroll around to find what he/she is looking for.
The name attribute is used to create a named anchor. The name of the anchor can be
any text you care to use.
You should notice that a named anchor is not displayed in a special way.
To link directly to the "down" section, add a # sign and the name of the anchor to the
end of a URL, like this:
A hyperlink to the Useful Tips Section from WITHIN the file "[Link]" will look
like this:
Tables
Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag),
and each row is divided into data cells (with the <td> tag). The letters td stands for
"table data," which is the content of a data cell. A data cell can contain text, images, lists,
paragraphs, forms, horizontal rules, tables, etc.
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
If you do not specify a border attribute the table will be displayed without any borders.
Sometimes this can be useful, but most of the time, you want the borders to show.
To display a table with borders, you will have to use the border attribute:
<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>
Headings in a Table
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Table Tags
Tag Description
Unordered Lists
An unordered list is a list of items. The list items are marked with bullets (typically
small black circles).
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Coffee
Milk
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
Ordered Lists
An ordered list is also a list of items. The list items are marked with numbers.
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
1. Coffee
2. Milk
Inside a list item you can put paragraphs, line breaks, images, links, other lists, etc.
Definition Lists
A definition list is not a list of items. This is a list of terms and explanation of the terms.
A definition list starts with the <dl> tag. Each definition-list term starts with the <dt>
tag. Each definition-list definition starts with the <dd> tag.
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
Coffee
Black hot drink
Milk
White cold drink
Inside a definition-list definition (the <dd> tag) you can put paragraphs, line breaks,
images, links, other lists, etc.
List Tags
Tag Description
A)
<html>
<head>
<title>Welcome to my Home Page</title>
</head>
<body bgcolor="blue">
My name is Harshit Kumar
</body>
</html>
The output is
The text color can also be changed, i.e. we can change the background color and text
color.
Write the code below and save as an .html file.
<html>
<head>
<title>Welcome to my Home Page</title>
</head>
<body bgcolor="red" text="yellow">
My name is Harshit Kumar
</body>
</html>
The output is
If you put <body bgcolor=”black”> or
<body bgcolor=”#FFE4C4”>, then you will get the same effect on the page color, i.e.
background color will be black. The # tells the browser that the number is hexadecimal.
bgcolor="red" bgcolor="#FF0000"
Similarly, by using the colour name or the code shown in the following table, you will
get the same colour results;
lightgoldenrodyello
lightcoral lightcyan lightgreen
w
#F08080 #E0FFFF #90EE90
#FAFAD2
mediumaquamarin
maroon mediumblue mediumorchid
e
#800000 #0000CD #BA55D3
#66CDAA
mediumspringgree
mediumpurple mediumseagreen mediumslateblue
n
#9370DB #3CB371 #7B68EE
#00FA9A
mediumturquois
mediumvioletred midnightblue mintcream
e
#C71585 #191970 #F5FFFA
#48D1CC
Font means a specific size and style of the text. Size means the width of the text, and
style means whether the text is Arial, Times New Roman, etc.
Type the following code in notepad and save the file as .html.
<html>
<head>
<title>
Using the Font tag
</title>
</head>
<body>
Q) Try the above code with font Batang, and print the output?
You can also specify the color with the font tag. i.e. color is another attribute of the font
tag. For example
Type the following code in notepad and save the file as .html.
<html>
<head>
<title>
Using the Font tag
</title>
</head>
<body>
Here is normal text without any font tag. <br>
<html>
<head>
<title>
Using the Font tag
</title>
</head>
<body>
Here is normal text without any font tag. <br>
<font face="arial" size="4" color=”blue”> This is a text with font type Arial and
font size 4</font>
</body>
</html>
</body>
</html>
To align the text means whether the text will appear on the left of the page or
right of the page or center of the page.
If there was no <p> tag, then two statements “My name is Harshit Kumar” and “I am a
student of University of Suwon” would come one after the other on the same line.
Whereas <p> tag inserted a new line between the two statements, doing some what the
same as <br> tag.
If you notice the output very carefully there is some difference between <p> tag and
<br> tag.
Q) What is the difference between the <p> tag and <br> tag?
A) The difference is <p> tag inserts a double new line between two statements whereas
<br> tag inserts single new line between two statements. Actually <p> tag means
paragraph tag, and <p> tag indicates the browser to start a new paragraph
<html>
<head>
<title>
</title>
</head>
</html>The output is
So, You can see that the second statement is aligned towards the right. Similarly the
align attribute of <p> tag can be used as ‘left’ or ‘center’.
Q) Try the above code with <p align=”left”> and also with <p align=”center”>? Show
what the output is?
Creating a link to a new page mean that you make one web page which contains a link to
another page and when you click on the link, another page opens. For example
Now what you will see in the output is, an underline below ‘Click here’ and the color will
be blue. This is a link, which links to a new page, and all the links appear as blue color i.e.
The output will be
Now you can type the code below and save as [Link], remember that [Link]
should be saved in the same directory which contains [Link].
<html>
<head>
<title>This is my hobby page</title>
</head>
<body>
<b>My hobbies are</b><br>
<p align="center">Football</p>
<p align="center">Listening Music </p>
<p align="center">Reading</p>
</body></html>
After clicking on the ‘click here’, a new page [Link] will open, and the output will be
My hobbies are
Football
Listening Music
Reading
Q) What will happen if the <a> tag is used as follows, and use click on “click here”
<a href=””> click here </a> ?
A) The same page will be refreshed again.
I listed above my hobbies; there is a tag which helps in listing. The name of the tag is
<UL> tag. <UL> tag is also known as Un-ordered List tag.
Write the code below which does not use <UL> tag, and save as [Link].
<html>
<head>
<title>This is my hobby page</title>
</head>
<body>
<b>My hobbies are</b><br>
<p>Football</p>
<p>Listening Music </p>
<p>Reading</p>
</body></html>
After clicking on the ‘click here’, a new page [Link] will open, and the output will be
My hobbies are
Football
Listening Music
Reading
So, there is not proper indentation. The hobbies football, listening music, reading
should appear towards the right.
<html>
<head>
<title>This is my hobby page</title>
</head>
<body>
<b>My hobbies are</b><br>
<ul>
<p>Football</p>
<p>Listening Music </p>
<p>Reading</p>
</ul>
</body></html>
Football
Listening Music
Reading
So, now the hobbies football, Listening music, Reading are indented towards the right.
Q) How can I have a bullet (dark solid circle) before each hobby?
A) There is different tag called as <LI> which is used with the <UL> tag.
</body>
</html>
So, the output is
My hobbies are
Football
Listening Music
Reading
What I have done, I have replaced the <p> tag with the <li> tag, still keeping the <ul> tag.
<html>
<head>
<title>This is my hobby page</title>
</head>
<body>
<b>My hobbies are</b><br>
<ol>
<li>Football</li>
<li>Listening Music </li>
<li>Reading</li>
</ol>
</body>
</html>
1. Football
2. Listening Music
3. Reading
Nested Lists
<html>
<head>
<title>Country visit</title>
</head>
<body>
<b>The countries and cities that I have visited are</b><br>
<UL>
<li>Oman</li>
<UL>
<li>Muscat</li>
<li>Salalah</li>
<li>Nizwa</li>
</UL>
<li>South korea</li>
<ul>
<li>Seoul</li>
<li>Suwon</li>
<li>incheon</li>
</Ul>
</UL>
</body>
</html>
Oman
o Muscat
o Salalah
o Nizwa
South korea
o Seoul
o Suwon
o incheon
Oman and South Korea are countries. Muscat, Salalah, Nizwa are cities in Oman whereas
Seoul, Suwon, Incheon are cities in South Korea.
Please type the following code in notepad and save as .html file.
<html>
<head>
<title>mail</title>
</head>
<body>
My name is Firaol. <br>
I am studying at University of Ambo<br>
To mail me, Please <a href="[Link] here</a>
</body>
</html>
My name is Firaol.
I am studying at University of Ambo
To mail me, Please Click here
When you will click on “Click here”, mail client will open, through which you can send
email.
Create an External Link
When you visit a web site, you find links to other websites. When you click on the
link, another web site opens. Such a link which on clicking opens another website is
called as external link
Please type the following code in notepad and save as .html file.
<html>
<head>
<title>mail</title>
</head>
<body>
My name is Firaol. <br>
I am studying at University of Ambo<br>
</html>
My name is Firaol.
I am studying at University of Ambo
The sites I visit for fun are
1. Yahoo
2. Hotmail
So, when you will click on “Yahoo”, yahoo website will open, and if you will click on
“Hotmail”, Hotmail website will open.
Insert Graphics
Most of the websites that you visit contain graphics along with text. So graphics
need to be inserted in a web page.
To understand this, you need an image file, please download an image file from the
internet or locate for an image file on your computer. I have got an image file by the
name of “[Link]”.
<html>
<head>
<title>mail</title>
</head>
<body>
My name is Firaol. <br>
I am studying at University of Ambo<br>
Below is the map of Asia<br>
</body>
</html>
<li>Aerosmith</li>
<li>Savage Garden</li>
<li>Celin Deon</li>
<li>Guns & Roses</li>
<li>Britny Spears</li>
<li>50 Cents</li>
<li>Richard Marx</li>
<li>Elton John</li>
<li>Bryan Adams</li>
<li>All Saints</li>
<li>Backstreet Boys</li>
<li>Bon Jovi </li>
<li>Eminem</li>
<li>Enrique Iglesias</li>
<li>Eric Clapton</li>
<li>George Michael</li>
<li>Faithless</li>
<li>Queeb</li>
<li>Cher</li>
<li>Janet Jackson</li>
<li>Jennifer Lopez</li>
<li>Jewel</li>
<li>Kylie Minogue</li>
</ul>
</p>
<a name="read"> <p align="center">Reading </p></a>
My favorites are <br>
<ul>
<li>Computer Books</li>
<li>Fiction</li>
<li>Non-fiction</li>
<li>Science</li>
<li>Newspaper</li>
</ul>
</ul>
</body></html>
Now when you will click on “soccer”, [Link] will open and scroll down, so that
you can see the details about soccer. Similarly, when you click on “music” , [Link]
will open and if required, page will scroll down, so that you can see the details about
music.
<html>
<head>
<li>Faithless</li>
<li>Queeb</li>
<li>Cher</li>
<li>Janet Jackson</li>
<li>Jennifer Lopez</li>
<li>Jewel</li>
<li>Kylie Minogue</li>
</ul>
</p>
<a name="read"> <p align="center">Reading </p></a>
My favorites are <br>
<ul>
<li>Computer Books</li>
<li>Fiction</li>
<li>Non-fiction</li>
<li>Science</li>
<li>Newspaper</li>
</ul>
</ul>
</body></html>
we will learn about
Using an Image as a Link
Aligning Images
The above code is similar to the previous code, but the only difference is instead of text,
now there are images. Earlier clicking on text opens a new page, but now clicking on
link will open a new page.
Aligning Images
With the <img src= > tag, you can specify the width and height of the image i.e.
<img src=” “ width=” “ height=” “>
<html>
<head>
<title> First Page</title>
</head>
</body>
My name is Fraol. <br>
I am teaching at Ambo University <br>
My hobbies are <br>
<a href="[Link]#soccer"><img src="[Link]" alt=soccer width=100
height=100></a><br>
<a href="[Link]#music"><img src="[Link]" alt=music width=100
height=100></a><br>
<a href="[Link]#read"><img src="[Link]" alt=book width=100
height=100></a><br>
</body>
</html>
The above code will reduce the size of the image, and make the web page look more
sensible.
You have some flexibility when displaying images. You can have images separated from
text and aligned to the left or right or centered. Or you can have an image aligned with
text. Try several possibilities to see how your information looks best.
You can align images to the top or center of a paragraph using the ALIGN= attributes
TOP and MIDDLE. i.e.
Let us take an example, and see how image and text look without align attribute and
with align attribute. First take an example of how image and text look without align
attribute.
<html>
<head>
<title> First Page</title>
</head>
</body>
My name is Firaol. <br>
I am teaching at Ambo University <br>
My hobbies are <br>
<a href="[Link]#soccer"><img src="[Link]" alt=soccer width=100
height=100></a>Soccer<br>
<a href="[Link]#music"><img src="[Link]" alt=music width=100
height=100> </a>Music<br>
<a href="[Link]#read"><img src="[Link]" alt=book width=100
height=100></a>Book<br>
</body>
</html>
Soccer
MusicMusic
Book
The output shows that, the text is at the bottom of the image, whereas it looks better to
be text in the middle of the image or at the top of the image.
Let us take another example, and see how text and image text and image look with align
attribute. We have used align=middle.
<html>
<head>
<title> First Page</title>
</head>
</body>
My name is Harshit Kumar. <br>
align=middle></a>Soccer<br>
<a href="[Link]#music"><img src="[Link]" alt=music width=100
height=100 align=middle></a>Music<br>
<a href="[Link]#read"><img src="[Link]" alt=book width=100
height=100 align=middle></a>Book<br>
</body>
</html>
The output can be seen on the browser.
Tables are very useful while creating HTML pages; especially tables solve the alignment
problem. A table tag has headings where you explain what the columns/rows include,
rows for information, and cells for each item. In the following table, the first two rows
contain the heading information, each detail row explains an HTML table tag, and each
cell contains a paired tag or an explanation of the tag's function.
Table Elements
Element Description
<TABLE> ... defines a table in HTML. If the BORDER attribute is present, your
</TABLE> browser displays the table with a border.
<CAPTION> ... defines the caption for the title of the table. The default position of
</CAPTION> the title is centered at the top of the table. The attribute
ALIGN=BOTTOM can be used to position the caption below the table.
NOTE: Any kind of markup tag can be used in the caption.
<TR> ... </TR> specifies a table row within a table. You may define default attributes
for the entire row: ALIGN (LEFT, CENTER, RIGHT) and/or VALIGN
(TOP, MIDDLE, BOTTOM).
<TH> ... </TH> defines a table header cell. By default the text in this cell is bold and
centered. Table header cells may contain other attributes to
determine the characteristics of the cell and/or its contents.
<TD> ... </TD> defines a table data cell. By default the text in this cell is aligned left
and centered vertically. Table data cells may contain other attributes
to determine the characteristics of the cell and/or its contents.
<CENTER>
<table border=1>
<tr>
</tr>
</table>
</CENTER>
The output on the browser is
<html>
<head>
<title> Using Table Tag</title>
</head>
<body>
<table border=1>
<caption> Time Table for October-November 2023</caption>
<tr>
<th></th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thrusday</th>
<th>Friday</th>
</tr>
<tr>
<td>9:30-10:20</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><font color="blue">109</font></td>
</tr>
<tr>
<td>10:30-11:20</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><font color="blue">109</font></td>
</tr>
<tr>
<td>11:30-12:20</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><font color="blue">109</font></td>
</tr>
<tr>
<td>12:30-1:20</td>
<td>-</td>
<td>-</td>
<td><font color="blue">312</font></td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>1:30-2:20</td>
<td>-</td>
<td><font color="blue">306</font></td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>2:30-3:20</td>
<td>-</td>
<td><font color="blue">306</font></td>
<td>-</td>
<td><font color="blue">309</font></td>
<td>-</td>
</tr>
<tr>
<td>3:30-4:20</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><font color="blue">309</font></td>
<td>-</td>
</tr>
<tr>
<td>4:30-5:20</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td><font color="blue">309</font></td>
<td>-</td>
</tr>
<table>
</body>
</html>
9:30-10:20 - - - - 109
10:30-11:20 - - - - 109
11:30-12:20 - - - - 109
12:30-1:20 - - 312 - -
1:30-2:20 - 306 - - -
3:30-4:20 - - - 309 -
4:30-5:20 - - - 309 -
Special characters are composed of short sequence of characters that are translated by
the browser and displayed as a single character.
Special characters begin with an ampersand(&) and end with a semicolon (;), for
example  , which is used for giving spaces between words or characters
</head>
<body>
My name is Harshit Kumar.
</body>
</html>
The output is
My name is Harshit Kumar.
Although I gave so many spaces between “Harshit” and “Kumar”, still the output shows
only one space.
This means that browser shrink the spaces, so to insert spaces, we need .
<body>
My name is Harshit Kumar.
</body>
</html>
The output is
My name is Harshit Kumar.
Thank you!
By Firaol