Lecture 2 - HTML
Lecture 2 - HTML
Lecture 2 - HTML
Introduction to HTML
⦿ The highest hierarchy is <html>. <html> tags has a few child tags such as
<head> and <body>.
⦿ Child tags must be placed inside the parent tag. As you see <title> is
placed inside the <head> tag.
⦿ <body> tags can contains most of other tags such as <h1>, <table>, <p>,
and many more.
⦿ Inside <title>… </title> you can write any text as a title of home page.
⦿ The purpose of the <body> tag is to define the HTML element that
contains the body of the HTML document.
HTML BASIC TAGS
⦿ <body>…</body>
<body bgcolor = “colorname”> - default color
is white
<body background = “image.gif/.png/.jpg”>
The image must be located in the same
location as the HTML file.
Image file named ‘cat’ is located
on the desktop. This is a JPEG
file, its extension is .jpg.
<body background="cat.jpg">
Small image will be
tiled to fit the
browser window size
A large image will
fit nicely in the
browser window size
<body
background="catbg.gif">
OTHER TAGS
⦿ Headings
For header of a page, to indicate title
<h1> … <h6>
Eg: <h1>Welcome</h1>
⦿ Paragraph
<p>Welcome to my homepage</p>
⦿ Line break
<br>
⦿ Comment
<!– This is a welcome page -->
<H1>… <H6>
<h1>Hello</h1>
<h2>Hello</h2>
<h3>Hello</h3>
<h4>Hello</h4>
<h5>Hello</h5>
<h6>Hello</h6>
Welcome to my homepage
⦿ <pre>…</pre>
To preserve the appearance of information
<pre>
Name : Hana
Course: Computing
</pre>
⦿ <blockquote>… </blockquote>
Used to indicate quotation
OTHER TAGS
⦿ <hr> Horizontal line
width, size, align
Eg: <hr size= “3”> <hr width=“50%”>
<hr align = “right”>
<hr size=“3” align=“left”>
⦿ <imgsrc="home.jpg" width="100"
height="100" alt="Back to Home" >
<html>
<head>
<title>My First Homepage</title>
</head>
<body bgcolor="yellow">
<h1>Hello</h1>
Welcome to my homepage
<br>
<img src="cat.jpg">
</body>
</html>
EXERCISES
⦿ Write the code to produce this page:
ANSWER
<html>
<head><title>Exercise</title>
</head>
<body>
<img src = "fblogo.jpg">
</img>
</body>
</html>
EXERCISES
<html>
<head><title>Exercise</title>
</head>
<body>
<img src = "fblogo.jpg"
align="right">
</img>
</body>
</html>