1
Introduction to Web Technology �(CSE505)
chapter 1 / part 1
Introduction to HTML5
LEARNING OUTCOME
2
Introduction
3
First HTML Example
This first example displays the message Welcome to HTML! in the browser.
4
The <!DOCTYPE> Declaration
HTML documents must start with: Document Type Definition (DTD)
5
Possible versions: HTML 4.01, XHTML 1.0 (Transitional or Strict), XHTML 1.1, HTML 5
Blank lines
We include blank lines (lines 2 and 10) to make our documents easier to read
6
Comments: �<!-- --> Tag
7
<html> </html> Tag
8
The <head> Section
- Contains information that doesn’t show directly on the viewable page
- Starts after the <html> declaration
- Begins with <head> and ends with </head>
9
<head> Section:�1- <title> tag
-defines a title in the browser toolbar
-provides a title for the page when it is added to favourites or Bookmarks
-displays a title for the page in search engine
10
Note: try to make the title as accurate and meaningful as possible!
<head> Section:�2- <Meta> tag
- Metadata is data about data.
- The <meta> tag provides (information about the HTML document.
11
<head> Section:�2- <Meta> tag
12
<meta charset="UTF-8">
<meta name="description" content="HTML tutorial"/>
<meta name="keywords" content="html, web design, styles"/>
<meta name="author" content=“Nada"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head> Section:�2- <Meta> tag
-Here is an example of a web page with and without the viewport meta tag:
13
<head> Section:�3- < script > tag
14
<head> Section:�3- < script > tag
15
<!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>
<head> Section:�4- < style > tag
16
<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>
<body> Section
17
The Heading Element
18
<h1> to <h6> Define headers
<h1> defines the largest header
<h6> defines the smallest header
<h1>Heading Level 1</h1>
<h2>Heading Level 2</h2>
<h3>Heading Level 3</h3>
<p> ,<br/> tags
19
Example
<p>Contact<br />� 6150 Sennott Square<br />� University of Pittsburgh<br>� Pittsburgh, PA 15260</p>
Text Formatting
20
Text Formatting (Example)
21
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<b> Hello#1 </b>
<em> Hello#2 </em>
<i> Hello#3 </i>
<u> Hello#4 </u>
<del> Hello#5 </del>
<sup> Hello#6 </sup>
<sub> Hello#7 </sub>
<pre> Hello#8 </pre>
<blockquote>Hello#9</blockquote>
</body>
</html>
Output:
Text Formatting (Another Example)
22
Output:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<h1>Notice</h1>
<p>This is a <em>sample</em> Web page.</p>
<p><pre>Next paragraph:
preformatted.</pre></p>
<h2>More Info</h2>
<p>Specifically, we’re using XHMTL 1.0 transitional.<br />
Next line.</p>
</body>
</html>
Attributes, Links, Images,�Lists, and Tables
23
Links & Anchor Element <a>
24
<a href="http://yahoo.com " target="_blank" >Yahoo</a>
<a href="index.html">Home</a>
<h2 id="section1">Intro</h2>
<a href="#section1">Goto intro</a>
Links & Anchor Element <a>
25
<a href="http://yahoo.com" target="_blank">Yahoo</a>
<a href="mailto:me@hotmail.com">me@hotmail.com</a>
<a href="http://yahoo.com" target=“ _self ">Yahoo</a>
Links to the Same Document – Example
26
<h1>Table of Contents</h1>
<p> <a href="#section1"> Introduction </a> <br/>
<a href="#section2">Some background</a> <br/>
<a href="#section3">Project History</a> <br/>
...the rest of the table of contents... </p>
<!-- 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="section3 ">Project History</h3>
... Section 3 follows here ...
Images:<img> tag
27
<img src="url" alt="some_text" width="width" height= "height " >
src | Location of image file (relative or absolute) |
alt | Substitute text for display (e.g. in text mode) |
height | Number of pixels of the height |
width | Number of pixels of the width |
border | Size of border, 0 for no border |
Images:<img> tag
28
<img src="html5.gif" alt="HTML5 icon" width="300" height="300" >
<a href="default.asp">
<img src="html5.gif" alt="HTML5 icon" width="300" height="300" >
</a>
<img src="imeges/html5.gif" alt="HTML5 icon" width="300" height="300" >
Lists types:
- Bulleted items.
- Numbered items.
-a list of items, with a description of each item.
Note: Browser inserts a blank line before & after the list (block-level element)
29
Ordered Lists: <ol> Tag
<ol type="1">
<li>Apple</li>
<li>Orange</li>
<li>Grapefruit</li>
</ol>
Attribute values for type are:
1, A, a, I, or I
Note: 1 is the default value
30
Unordered Lists: <ul> Tag
<ul type=" circle ">
<li>Apple</li>
<li>Orange</li>
<li>Grapefruit</li>
</ul>
Attribute values for type are:
disc, circle and square
Note: square is the default value
31
Definition lists: <dl> tag
<dl>
<dt>HTML</dt>
<dd>A markup language ..</dd>
<dt>CSS</dt>
<dd>Language used to … </dd>
</dl>
32
HTML Special Characters
33
£
£
British Pound
€
€
Euro
"
"
Quotation Mark
¥
¥
Japanese Yen
—
—
Em Dash
Non-breaking Space
&
&
Ampersand
>
>
Greater Than
<
<
Less Than
™
™
Trademark Sign
®
®
Registered Trademark Sign
©
©
Copyright Sign
Symbol
HTML Entity
Symbol Name
Tables
34
Tables
A table can be split into three distinct sections:
Note: Even if the tfoot section in the code was before the tbody, the tfoot content will display at the bottom in the table.
- Same applies on thead it always comes on the top of the table
35
Tables
36
Element | Definition |
<tr> | Defines individual table rows |
<th> | Defines a header cell |
<td> | Contains table data elements. |
<tr>
<tr>
<th>
<th>
<td>
<td>
Tables
Table with Header & Border
<table border="1" >�<tr>� <th>Header 1</th>� <th>Header 2</th>�</tr>
�<tr>� <td>row 1, cell 1</td>� <td>row 1, cell 2</td>�</tr>�</table>
Tables without Header & Borders
<table border="0" >
<tr>
<td>row 1, cell 1</td>
<td>row 2 , cell 2</td>
</tr>
<tr>
<td> row 2, cell 1 </td>
<td> row 2, cell 2 </td>
</tr>
</table>
37
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
Tables in summary
38
Table - Example
39
Table – Example cont..
40
Table – Example cont..
41
42
cell
cell
cell
cell
cell
cell
cell
cell
Cell Spacing and Padding
Cell Spacing and Padding- Example
43
<table cellspacing="15" cellpadding="0">
<tr>
<td>First</td>
<td>Second</td>
</tr>
</table>
<br/>
<table cellspacing="0" cellpadding="10">
<tr>
<td>First</td>
<td>Second</td>
</tr>
</table>
Row and Column Spans
44
45
Row and Column Spans
cell[1,1]
cell[1,2]
cell[2,1]
colspan="1"
colspan="1"
colspan="2"
cell[1,1]
cell[1,2]
cell[2,1]
rowspan="2"
rowspan="1"
Row and Column Spans - Example
46
<table cellspacing="0">
<tr>
<td>Cell[1,1] </td>
<td colspan="2">Cell[2,1]</td>
</tr>
<tr>
< td >Cell[1,2]</td>
<td rowspan="2">Cell[2,2]</td>
< td >Cell[3,2]</td>
</tr>
<tr>
<td>Cell[1,3]</td>
<td>Cell[2,3]</td>
</tr>
</table>
Could you predict the output ?
Cell[2,3]
Cell[1,3]
Cell[3,2]
Cell[2,2]
Cell[1,2]
Cell[2,1]
Cell[1,1]
Using <div> & <span> �block & inline elements
47
Block and Inline Elements
48
The <div> Tag
49
<div style="backgroundcolor:black;color:white;padding:20px;">
<h2>London</h2>
<p>London is the capital city of England...</p>
<p>Standing on the River Thames, London has...</p>
</div>
The <span> Tag
50
<h1> My <span style="color:red">Important</span> Heading</h1>
The <nav> Tag
51
To Explore .. (Self driven learning activity).
52