IT 123 (Week 02 & 03)
IT 123 (Week 02 & 03)
___________________________________________________
_____________________________________________________
WEEK 2 & 3
COURSE OUTLINE
HTML Elements
HTML Attributes
HTML Formatting
Objectives:
General Objective
To understand how to add markup to the text that appears on your pages. You will learn about
Structural markup: the elements that you can use to describe both headings and paragraphs.
Each chapter in this module contains a major lesson involving the basics of Web page coding and
HTML editing tool. The units are characterized by continuity, and are arranged in such a manner that the
present unit is related to the next unit. For this reason, you are advised to read this module. After each
unit, there are exercises to be given. Submission of task given will be every Monday during your
scheduled class hour.
HTML Elements
HTML elements are written with a start tag, with an end tag, with the content in between:
<tagname>content</tagname>
Note:
Don’t forget the end tag.
Some HTML elements will display correctly, even if you forget the end tag:
<html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
Centering content
You can use <center> tag to put any content in the center of the page or any table cell.
For example:
<!DOCTYPE html>
<html>
<head>
<title>Centering Content Example</title>
</head>
<body>
</body>
</html>
Output:
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
Function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
Output:
Nonbreaking Spaces
Suppose you want to use the phrase “12 Angry Men.” Here, you would not want a browser to split the
“12, Angry” and “Men” across two lines.
In cases, where you do not want the client browser to break text, you should use a nonbreaking space
entry instead of a normal space.
Example
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
</body>
</html>
HTML elements with no content are called empty elements. Empty elements can be “closed” in
the opening tag like this: <br> <br />. HTML does not require empty elements to be closed. But if you
want stricter validation, or you need to make your document readable by XML parsers, you should close
all HTML elements. The following are empty elements:
For example:
Output:
<!DOCTYPE html>
<html>
<body>
<p>The Earth <br> gets one hundred tons heavier everyday <br> due to falling
space dust.</p>
</body>
</html>
Output:
<!DOCTYPE html>
IT<html>
123: Web Development 1
<body>
SOUTH EAST ASIAN INSTITUTE OF TECHNOLOGY, INC.
<p>Venus id the only planet
Page 6 of 19that rotates clockwise.</p>
<hr>
<p>Jupiter is bigger than all the other planets combined.</p>
</body>
</html>
Output:
HTML Attributes
An attribute is used to define the characteristics of an HTML element and is placed inside the element’s
opening tag. All attributes are made up of two parts: a name and a value:
The name is the property you want to set. For example, the paragraph <p> element in the
example carries attribute whose name is align, which you can use to indicate the alignment of
paragraph on the page.
The value is what you want the value of the property to be set and always put within
quotations. The below example shows three possible values of align attribute: left, center and
right.
Example
<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align=”left”>This is left aligned</p>
<p align=”center”>This is center aligned</p>
<p align=”right”>This is right aligned</p>
</body>
</html>
Output
The Id Attribute
The Id attribute of an HTML tag can be used to uniquely identify any element within an HTML page.
There are two primary reasons that you might want to use an id attribute on an element:
If an element carries an id attribute as a unique identifier, it is possible to identify just that
element and its content.
If you have two elements of the same name within a Web page (or style sheet), you can use the
id attribute to distinguish between elements that have the same name.
Example
<!DOCTYPE html>
<html>
<head>
<title>ID Attribute</title>
</head>
<body>
</body>
</html>
Output
<head>
<title>The style attribute</title>
</head>
<body style=”background-color:ligthblue;”>
<h1>This is heading</h1>
<p>This is paragraph</p>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>the Style attribute</title>
</head>
<body>
</body>
</html>
Output
HTML Fonts
The font-family property defines the font to be used for an HTML element:
Example
<!DOCTYPE html>
<html>
<head>
<title>the Style attribute</title>
</head>
<body>
Example
<!DOCTYPE html>
<html>
<head>
<title>the Style attribute</title>
</head>
<body>
</body>
</html>
Output
Example
<!DOCTYPE html>
<html>
<head>
<title>the Style attribute</title>
</head>
<body>
<h1 style=”text-align:center;”>This is heading</h1>
<p>This is paragraph</p>
IT</body>
123: Web Development 1
</html>
Internationalization Attributes
There are three internationalization attributes, which are available for most (although not all) XHTML
elements.
dir
lang
xml:lang
Value Meaning
ltr Left to right(the default value)
rtl Right to left(for languages such as Hebrew or Arabic that are read right to left)
Example
<!DOCTYPE html>
<html dir=”rtl”>
<head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-to-left directed text.
</body>
</html>
Example
<!DOCTYPE html>
<html lang=”en”>
<head>
<title>English Language Page</title>
</head>
<body>
This page is using English Language
</body>
</html>
Output
Generic Attributes
Here’s a table of some other attributes that are readily with many of the HTML tags.
Attribute Options Function
align Right, left, center Horizontally aligh tags
Vertically aligns tags within an HTML
valign Top, middle, bottom
element.
Numeric, hexadecimal, Places a background color behind an
bgcolor
RGB values element
Places a background image behind an
background URL
element
Names an element for use with Cascading
id User defined
Style Sheets
Classifies an element for use with
class User defined
Cascading Style Sheets
Specifies the width of tables, images, or
width Numeric value
table cells.
Specifies the height of tables, images, or
height Numeric value
table cells.
IT 123: Web Development 1
HTML Formatting
If you use a word processor, you must be familiar with the ability to make text bold, italicized, or
underlined; these are just three of the ten options available to indicate how text can appear in HTML
and XHTML.
Bold Text
Anything that appears within <b>…</b> element, is displayed in bold as shown below:
Example
<!DOCTYPE html>
<html dir=”rtl”>
<head>
<title>Bold Text Example</title>
</head>
<body>
</body>
</html>
Output
Italic text
Anything that appear within <i>…</i> element is displayed in italicized as shown below:
Example
<!DOCTYPE html>
<html dir=”rtl”>
<head>
<title>Italic Text Example</title>
</head>
<body>
</body>
</html>
Underline Text
Anything that appear within <u>…</u> element, is displayed with underline as shown below:
Example
<!DOCTYPE html>
<html dir=”rtl”>
<head>
<title>Underline Text Example</title>
</head>
<body>
</body>
</html>
Output
Strike Text
Anything that appears within <strike>…</strike> element is displayed with strikethrough, which is a thin
line through the text as shown below:
Example
<!DOCTYPE html>
<html dir=”rtl”>
<head>
<title>Strike Text Example</title>
</head>
<body>
</body>
</html>
Superscript Text
The content of a <sup>…</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.
Example
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
</body>
</html>
Output
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the same as the
characters surrounding it, but is displayed half a character's height beneath the other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Subscript Text Example</title>
</head>
<body>
</body>
</html>
Output
Grouping Content
The <div> and <span> elements allow you to group together several elements to create sections or
subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element to indicate
that all of the elements within that <div> element relate to the footnotes. You might then attach a style
to this <div> element so that they appear using a special set of style rules.
Example
<!DOCTYPE html>
<html>
<head>
<title>Div Tag Example</title>
</head>
<body>
<div id=”menu” align=”middle”>
<a href=”/index.html”>HOME</a> |
<a href=”/about/contact_us.html”>CONTACT</a> |
<a href=”/about/index.html”>ABOUT</a> |
</div>
<div id=”content” align=”left” bgcolor=”grey”>
<h5>Content Articles</h5>
<p>Actual content goes here. . . . .</p>
</div>
</body>
IT</html>
123: Web Development 1
The <span> element, on the other hand, can be used to group inline elements only. So, if you have a
part of a sentence or paragraph which you want to group together, you could use the <span> element
as follows.
Example
<!DOCTYPE html>
<html>
<head>
<title>Span Tag Example</title>
</head>
<body>
<p>This is the example of <span style=”color:green”>span tag</span> and the <span
style=”color:red”>div tag</span> along with CSS</p>
1. Briefly describe the different empty HTML elements and their usage.
2. Can a single text link point to two different web pages?
3. How do you create a link that will connect to another web page when clicked?
4. How do you create text on a webpage that will allow you to send an email when clicked?
5. How are active links different from normal links?
Test Yourself!
1. Add a tooltip to the paragraph below with the text “My Goal”
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p>W3Schools is a web developer's site.</p>
</body>
</html>
2. Change the size of the image to 250 pixels wide and 400 pixels tall. (use any photo as long as it is
not pixilated.)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<img src="photo.jpg" width="104" height="142">
</body>
</html>
Challenge!
1. Choose a website that you would want to create (e.g Tupinians Pride website, Tourist Spots
website, Business websites, Sports website, etc.)
2. Try to use the new tags that have been discussed in this module.
3. In your notepad create a simple home page for your website containing its overview about your
website and other information that you would want to show as your first page.
After creating your home page save your html file as “index.html”.