Chapter 2 - Part 1
Chapter 2 - Part 1
(CoSc3121)
Chapter 2 (Part I)
Web Page Development Using HTML
<html>
<head>
<title>HTML Page</title>
</head>
<body>
<p>This is an example of a paragraph in HTML.</p>
</body>
</html>
What is HTML (cont...)
• Static—it is only display.
• Use other technologies to add dynamic function:
• Client-side (browser) scripting languages (JavaScript)
• Server-side programs (PHP, Java servlets)
<body>
** [all the HTML for display] **
: :
: :
</body>
</html>
Creating HTML documents (cont...)
• <HTML>……</HTML>
• These tags begin and end an HTML document
• Used to bracket an entire HTML document.
• Optional for most browsers.
• Attributes:
• lang = language code
• Language code indicates the primary language of the document.
• en = English
Creating HTML documents (cont...)
• <HEAD >……</HEAD>
• These tags are in the beginning of the document.
• Important information is stored in-between these tags including:
title, meta-data, styles, and programming scripts.
• Used to provide information about a web page.
• Nests within itself other tags like:
<base>, <meta> and <title>
Creating HTML documents (cont...)
• <base>
• Attribute: href = url
• Specifies the base pathname for all relative URLs in the document.
• No end tag.
• <meta>
• Used to provide information about a document.
• Keywords or descriptions to aid search engines.
• < title >……</ title >
• These tags are in-between the HEAD tags and contain the text that
appears in the title of the webpage.
• Usually appears on the title bar of the browser window.
Creating HTML documents (cont...)
• <BODY>…..</BODY>
• alink = color
• Sets the color of active links.
• link = color
• Sets the default color for all the links in a document.
• vlink = color
• Sets the color for the visited links.
• bgcolor = color
• Sets the color for the entire page.
Creating HTML documents (cont...)
• After you wrote your code on any text-file editor tool, save it with an
extension of htm or html.
• And open it with any browser. Your browser will display the contents
based on what you (the programmer) tell it to.
How to specify colors?
1. By specifying the color name.
• Some of the colors that are supported by browsers are:
aqua black blue fuchsia
gray green lime maroon
Navy olive purple red
Silver teal yellow white
• Many other colors are possible.
• Example:
<body text=“white”>
<body bgcolor=“yellow”>
How to specify colors? (cont...)
2. By specifying the red, green, blue or RGB components.
• Each color encoded in 8 bits.
• 00 means that the color is turned off; FF means fully turned on.
• Example:
<body text=“#FFFFFF” bgcolor=“#0000FF”>
Text Formatting in HTML
Paragraphs and Headings
• <Hn> ……. </Hn>
• Used to generate headings, 1 ≤ n ≤ 6.
• Six different levels of headings.
• <H1> is the largest, <H6> is the smallest.
• <P>
• Paragraph marker, used to separate text into paragraphs.
• End tag </P> is optional.
• A series of paragraph tags <p><p>…<p> with no intervening text is treated as
a single <p>.
Text Formatting in HTML (cont...)
• <BR>
• Used to indicate that the text following <BR> should begin on the
next line.
• The amount of line spacing is less than that of a <P> break.
• Example:
This is the first line. <br>
This is the second line. <br>
This is the third.
Text Formatting in HTML (cont...)
• <HR>
• Produces a horizontal line, which can be used to delimit sections.
• Length of the line can be specified.
• Examples:
<hr>
<hr size= "20"> [ noshade option possible ]
<hr width= "75%">
<hr align="right" width=120>
• Across full width of browser, 20 pixels thick, 75% of available page width,
and 120 pixels right-justified.
Text Formatting in HTML (cont...)
• <address> ……. </address>
• Supplies the contact information of the author.
• Generally formatted in italics, with a line break above and below.
• Example
<address>
Mr X Y<br>
Dept. of Information Systems <br>
Bahir Dar University <br>
Email: [email protected]
</address>
Text Formatting in HTML (cont...)
• <b> ……. </b>
• Displays the enclosed text in bold.
• <i> ……. </i>
• Displays the enclosed text in italics.
• <cite> ……. </cite>
• Tells the browser that this is a citation. Usually displayed in italics.
Text Formatting in HTML (cont...)
• <pre> ……. </pre>
• Allows browser to display carefully laid out text.
• Used to display program listings.
• Example:
<pre>
main()
{
int i, j;
abc ();
}
</pre>
Text Formatting in HTML (cont...)
• <sub> ……. </sub>
• Displays the enclosed text as subscript.
• <sup> ……. </sup>
• Displays the enclosed text as superscript.
• <font> ……. </font>
• Specifies the style of the enclosed text.
• Attributes:
• color = color name
• face = typeface
• size = value [1 to 7; 3 is the default]
Text Formatting in HTML (cont...)
• <center> ……. </center>
• Centers the enclosed elements horizontally on the page.
• <P align=option> ……. </P>
• Used to align a paragraph.
• Option can be left, right or center.
Text Formatting in HTML (cont...)
Example 1
<html>
<head>
<title> Title of the Document </title>
</head>
<body text="white" bgcolor= "blue">
This is the content of the document.
This is an <i> italic </i> font,
and this is <b> bold </b>.
</body>
</html>
Text Formatting in HTML (cont...)
Example 2
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1 align="center">My First Webpage</h1>
<p>Welcome to my first web page. I am writing this page using a text editor and plain old
html.</p>
<p>By learning html, I'll be able to create web pages like....<br>
which I am of course.</p>
</body>
</html>
Text Formatting in HTML (cont...)
Example 3
<html>
<head><title>Demonstration of Headings </title></head>
<body text="#FFFFFF" bgcolor="#0000FF">
<h1>This is a first level heading. </h1>
<h2>The second level</h2>
<h3>The third level</h3>
<h4>Fourth level. </h4>
<h5>Fifth level.</h5>
<h6>And, finally, the sixth .</h6>
A small amount of plain non-heading text.
</body>
</html>
Text Formatting in HTML (cont...)
Example 4
<html>
<head><title>Paragaph Aligning</title></head>
<body text=white bgcolor=green>
<h3>
<P ALIGN=CENTER> This paragraph will be aligned
at the center. Even as the browser window
size changes, the alignment remains the same. </P>
<P ALIGN=LEFT>This demonstrates left alignment. </P>
<P ALIGN=RIGHT>How about aligning by the right margin? </P>
</h3>
</body>
</html>
Text Formatting in HTML (cont...)
Example 5
<html>
<head><title>Layout Features 1</title></head>
<body text=yellow bgcolor=blue>
<h2> <pre>
begin
if (a > b)
then max := a;
else max := b;
end;
</pre> </h2>
<hr size=8 width=50%>
<hr>
<hr size=20 width="75%" noshade>
</body>
</html>
Text Formatting in HTML (cont...)
Example 6
<html>
<head><title>Layout Features 2</title></head>
<body text=yellow bgcolor=blue>
<h3>Extended Quotations</h3>
<blockquote>
<P>This is the first paragraph within
the BLOCKQUOTE environment. </P>
<P>Another paragraph starts here. </P>
We type some text here without explicitly
giving paragraph break.
</blockquote>
</body>
</html>
Text Formatting in HTML (cont...)
Example 7
<html>
<head><title> Superscript and Subscript </title></head>
<body text=white bgcolor=blue>
<h1> y = x <sup> 3 </sup> + 2 x <sup> 2 </sup> + 4 </h1>
<br>
<h2> W <sub> total </sub> = x <sup> 2 </sup> - 5 </h2>
</body>
</html>
END
of Part 1