Professional Documents
Culture Documents
CH 2
CH 2
By Tesfahun N.
Outline
❖ What is HTML
❖A web site will often contain many html files that link to
each other.
4
HTML Tags
❖HTML tags are the hidden keywords within a web page
that define how your web browser must format and
display the content
sacrificed
7
HTML page structure
❖HTML describes structure using two main
sections:
✓ <head>
✓ <body>
HTML Structure
❖HTML is included of “elements” and “tags”
• Begins with <html> and ends with </html>
definition (DTD)
➢It informs the web browser about the type and version
of HTML
10
HTML Tags
❖The <html> root element of an HTML page
❖Image Tags
<img src="logo.gif"/>
<body>
<a href="https://www.youtube.com/" title=
“youtube site">This is a link.</a>
<br />
<img src="logo.gif" />
<br />
<b>Bold</b> and <i>italic</i> text.
</body>
13
First HTML Page
test.html
<!DOCTYPE html>
<html>
<head>
<title>well came to WP</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html> 14
HTML Attributes
❖All HTML elements can have attributes
16
href Attribute
❖The <a> tag defines a hyperlink.
• Example
• <a href="https://www.google.com">Visit google</a>
The src Attribute
❖The <img> tag is used to embed an image in an
HTML page.
✓The src attribute specifies the path to the image to be
displayed:
• Example
• <img src="img_girl.jpg">
The alt Attribute
❖The required alt attribute for the <img> tag
specifies an alternate text for an image, if the
image for some reason cannot be displayed
• Example
✓Id,
✓Style,
✓Class,
✓Title etc
20
The width and height Attributes
• Example
• <img src="img_girl.jpg" width="500" height="600">
The style Attribute
❖The style attribute is used to add styles to an
element, such as color, font, size, and more.
• Example
• <p style="color:red;">This is a red paragraph.</p>
The lang Attribute
❖Adding the lang attribute inside the <html> tag, to declare
the language of the Web page.
<!DOCTYPE html>
<html lang="en">
<body>
...
</body>
</html>
Headings and Paragraphs
❖Paragraph Tags
<p>This is my first paragraph</p>
<p>This is my second paragraph</p>
✓<meta>
✓<script>
✓<link>
✓<style>
26
Header
<!DOCTYPE HTML>
HTML header
<html>
<head>
<title>My First HTML Page</title>
</head>
<body>
<p>This is some text...</p>
</body>
</html>
27
<head> Section: <title> tag
❖Title should be placed between <head> and </head> tags
<head>
<title>here is the title section </title>
</head>
28
<head> Section: <meta>
❖Meta tags additionally describe the content contained
within the page
29
<head> Section: <script>
❖The <script> element is used to embed scripts into an
HTML document
✓VBScript
30
The <script> Tag – Example
The <script> tag is used to embed a client-side script
(JavaScript). scripts-example.html
<!DOCTYPE HTML>
<html>
<head>
<title>JavaScript Example</title>
<script type="text/javascript">
function sayHello() {
document.write("<p>Hello World!<\/p>");
}
</script>
</head>
<body>
<script type= "text/javascript">
sayHello();
</script>
</body>
</html>
31
<head> Section: <style>
❖The <style> element embeds formatting
information (CSS styles) into an HTML page
style-example.html
<html>
<head>
<style type="text/css">
p { font-size: 12pt; line-height: 12pt; }
p:first-letter { font-size: 200%; }
span { text-transform: uppercase; }
</style>
</head>
<body>
<p>Styles demo.<br />
<span>Test uppercase</span>.
</p>
</body>
</html>
32
<body> Section: Introduction
❖The <body> section describes the viewable
portion of the page
❖Starts after the <head> </head> section
❖Begins with <body> and ends with </body>
<html>
<head><title>Test page</title></head>
<body>
<!-- This is the Web page body -->
</body>
</html>
33
Comments: <!-- --> Tag
❖Comments can exist anywhere between the <html></html> tags
34
Text Formatting
❖Text formatting tags modify the text between the opening tag and the closing tag
• Ex. <b>Hello</b> makes “Hello” bold
<b></b> bold
<i></i> italicized
<u></u> underlined
<sup></sup> Samplesuperscript
<sub></sub> Samplesubscript
<strong></strong> strong
<em></em> emphasized
<a href="stuff/cat.html">Catalog</a>
36
Hyperlinks: <a> Tag (2)
❖Link to an external Web site:
➢Always use a full URL, including "http://",
not just www.somesite.com
<a href="http://www.devbg.org"
target="_blank">BASD</a>
❖Link to an e-mail address:
<a href="mailto:bugs@example.com?subject=Bug+Report">
Please report bugs here (by e-mail only)</a>
37
Hyperlinks and Sections
❖Link to another location in the same document:
<a href="#section1">Go to
Introduction</a>
...
<h2 id="section1">Introduction</h2>
links-to-same-document.html
<h1>Table of Contents</h1>
<p><a href="#section1">Introduction</a><br />
<a href="#section2">Some background</A><br />
<a href="#section2.1">Project History</a><br />
...the rest of the table of contents...
<!-- The document text follows here -->
<h2 id="section1">Introduction</h2>
... Section 1 follows here ...
<h2 id="section2">Some background</h2>
... Section 2 follows here ...
<h3 id="section2.1">Project History</h3>
... Section 2.1 follows here ...
39
Miscellaneous Tags
➢<hr/>: Draws a horizontal rule (line):
➢<center></center>: Deprecated!
<center>Hello World!</center>
➢<font></font>: Deprecated!
<font size="3" color="blue">Font3</font>
<font size="+4" color="blue">Font+4</font>
40
Miscellaneous Tags – Example
misc.html
<html>
<head>
<title>Miscellaneous Tags Example</title>
</head>
<body>
<hr size="5" width="70%" />
<center>Hello World!</center>
<font size="3" color="blue">Font3</font>
</body>
</html>
41
Lecture II
…..
Loading
Ordered Lists: <ol> Tag
❖Create an Ordered List using <ol></ol>:
<ol type="1">
<li>Apple</li>
<li>Orange</li>
<li>Grapefruit</li>
</ol>
❖Attribute values for type are 1, A, a, I, or i
1. Apple i. Apple
2. Orange ii. Orange
3. Grapefruit a. Apple iii. Grapefruit
A. Apple b. Orange I. Apple
B. Orange c. Grapefruit II. Orange
C. Grapefruit III. Grapefru
it
43
Unordered Lists: <ul> Tag
❖Create an Unordered List using <ul></ul>:
<ul type="disk">
<li>Apple</li>
<li>Orange</li>
<li>Grapefruit</li>
</ul>
44
Definition lists: <dl> tag
❖Create definition lists using <dl>
➢Definition is indented
45
Lists – Example
<ol type="1"> lists.html
<li>Apple</li>
<li>Orange</li>
<li>Grapefruit</li>
</ol>
<ul type="disc">
<li>Apple</li>
<li>Orange</li>
<li>Grapefruit</li>
</ul>
<dl>
<dt>HTML</dt>
<dd>A markup lang…</dd>
</dl> 46
HTML Special Characters
Symbol Name HTML Entity Symbol
copyright Sign © ©
Registered Trademark Sign ® ®
Trademark Sign ™ ™
Less Than < <
Greater Than > >
Ampersand & &
Non-breaking Space
Em Dash — —
Quotation Mark " "
Euro € €
British Pound £ 47 £
Japanese Yen ¥ ¥
Block and Inline Elements
❖Block elements add a line break before and after them
❖Example:
div.html
in the document
span.html
<p>This one is <span style="color:red; font-
weight:bold">only a test</span>.</p>
<p>This one is another <span style="font-size:32px;
font-weight:bold">TEST</span>.</p>
51
HTML Tables
HTML Tables (2)
❖Tables represent tabular data
✓A table consists of one or several rows
✓Each row has one or more columns
• <td>First</td>
• <td>Second</td></tr>
• </table>
• <table cellspacing="0" cellpadding="15"
bgcolor="cyan" border="3px">
<tr><td>First</td>
• <td>Second</td></tr>
• </table>
56
Column and Row Span
• Table cells have two important attributes:
Colspan rowspan
colspan="1" colspan="1" rowspan="1"
rowspan="2"
58
HTML Forms
❖Forms are the primary method for gathering data
from site visitors
❖Create a form block with
<form></form>
The “method" attribute tells how the form
❖Example:
data should be sent – via GET or POST request
❖Radio buttons:
<input type="radio" name="title"
value="M." />
❖Radio buttons can be grouped, allowing only
one to be selected from a group:
<input type="radio" name="city" value="Lom" />
<input type="radio" name="city" value="Ruse" />
61
Other Form Controls
❖Dropdown menus:
<select name=“department">
<option value="Value 1"
selected="selected">cs</option>
<option value="Value 2">IS</option>
<option value="Value 3">IT</option>
</select>
❖Submit button:
<input type="submit" name="submitBtn"
value="Apply Now" />
62
Other Form Controls (2)
❖Reset button – brings the form to its initial state
<input type="reset" name="resetBtn"
value="Reset the form" />
❖Image button – acts like submit but image is
displayed and click coordinates are sent
<input type="image" src="submit.gif"
name="submitBtn" alt="Submit" />
63
Other Form Controls (3)
❖Password input – a text field which masks the entered
text with * signs
<input type="password" name="pass" />
64
Other Form Controls (4)
❖File input – a field used for uploading files
<input type="file" name="photo" />
❖Form labels are used to associate an explanatory
text to a form field using the field's ID.
<label for="fn">First Name</label>
<input type="text" id="fn" />
65
HTML Forms – Example
66
form.html
HTML Forms – Example
<form method="post" action="apply-now.php">
<input name="subject" type="hidden" value="Class" />
<fieldset style="width:300px"><legend>Personal Details</legend>
<table>
<tr>
<td><label for="fname">First Name</label></td>
<td><input type="text" name="fname" id="fname" /></td>
</tr>
<tr>
<td><label for="lname">Last Name</label></td>
<td><input type="text" name="lname" id="lname" /></td>
67
</tr>
form.html (continued)
<tr>
<td><label for="degree">Degree</label></td>
<td><select name="degree" id="degree">
<option value="BA">cs</option>
<option value="BS">SE</option>
<option value="MBA"
selected="selected">IT</option>
</select></td>
</tr>
<tr>
<td>Student ID</td>
<td><input type="text" name="s" /></td>
</tr>
68
Cont..
<tr>
<td>Password</td>
<td><input type="Password" placeholder="Enter Password"
name="s" /></td>
</tr>
<tr>
<td>Gender:</td>
<td>
<input name="gender" type="radio" id="gm" value="m" />
<label for="gm">Male</label>
<input name="gender" type="radio" id="gf" value="f" />
<label for="gf">Female</label></td>
</tr>
Cont.…
<tr>
<td></td>
<td><button type="submit">send</button>
</td>
</tr>
</fieldset>
</form>
What is Multimedia?
</video>
The HTML <audio> Element
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
HTML <audio> Autoplay
✓ To display maps
✓ To verify a bank id
Cont..
❖The <object> element defines an embedded object within
an HTML document.
HTML Graphics
• HTML Canvas
• HTML SVG
Thanks
?