Lecture 4
Lecture 4
HTML5
Structure
Syntax
Elements
Basic tags
2
HTML HISTORY
3
1989: The Birth of Web, HTTP
Berners-Lee invented the
World Wide Web, HTTP, and
wrote the first HTML page
4
1993: The Birth of Web, HTTP
Berners-Lee presented three important standards for WWW in
the 26th meeting of Internet Engineering Task Force
The URL
Hypertext Markup Language (HTML)
HTTP access protocol
CERN put the World Wide Web software in the public domain
5
1993: The Birth of Web, HTTP
Berners-Lee also presented
The first browser: NCSA’s “Mosaic” WWW client
Features include
Add bookmarks
Display images
Better UI
6
1994: The World Wide Web Consortium
(W3C)
7
2004: The HTML5
Browser developers got frustrated with W3C progress and
created a new standards committee to write the "HTML5"
spec, which adds:
Form input types
Audio/video
2d/3d Graphics
Data storage
New semantic tags
Drag-and-drop
...and more!
In 2008, the W3C adopted it as a standard
8
THE
HTML
9
HTM
L
HTML stands for HyperText Markup Language
11
HTML Syntax
The DOCTYPE
Elements
Attributes
Comments
12
The DOCTYPE
The <!DOCTYPE> declaration
Must be the very first thing in an HTML document
Its not an HTML tag
An instruction to the web browser about what version of
HTML the page is written in
Examples
HTML5:
<!DOCTYPE html>
HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01//EN" 13
"http://www.w3.org/TR/html4/strict.dtd">
The DOCTYPE: Example
15
HTML - Fundamentals
Paired Tags
<name attributes> stuff </name>
<b>text to be bolded</b>
<h1>level 1 heading text</h1>
Unpaired Tags
<name attributes />
<hr/>, <br/>
<img src=“url” width=‘100px’ height=’60px’/>
Comments
<!-- comment text -->
16
HTML – Fundamentals: Document
Structure
< HTML >
Header
Body
< / HTML>
17
HTML – Fundamentals: Document
Structure
<html>
<head>
<title> The title of your html page </title>
…
</head>
<body>
</html>
</body>
18
Various HTML Elements
19
Writing and Saving an HTML File
21
HTML – Fundamentals
<html>
<head>
</head>
<body>
Mike Tyler
PO Box 190387 Output
Hungry Horse, Mt 59919
</body>
</html>
22
HTML - Fundamentals
<html>
<head>
</head>
<body>
<h1>Mike Tyler</h1>
PO Box 190387<br>
Hungry Horse, Mt Output
59919<br>
</body>
<html> 23
HTML - Fundamentals
Attributes
<html>
<head>
</head>
<body>
<font face=“Arial" color="red" size="3">
<h1>Mike Tyler</h1>
PO Box 190387<br>
Hungry Horse, Mt Output
59919<br>
</font>
</body>
28
HTML - Fundamentals
<html>
<head>
</head>
<body>
<p align="center">
<font face="Arial" color="red" size="3">
<h1>Mike Tyler</h1>
Output
PO Box 190387<br>
Hungry Horse, Mt
59919<br></font>
</p>
</body> 29
HTML - Fundamentals
<html>
<head>
</head>
<body>
<p align="center">
<font face="Arial" color="red" size="3">
<h1>Mike Tyler</h1>
PO Box 190387<br>
Hungry Horse, Mt 59919<br></font>
<img src="file:///c:/mike.jpg"/>
</p>
</body>
<html>
Outpu
30
HTML - Fundamentals
<html>
<head>
</head>
<body>
<p align="center">
<font face="Arial" color="red" size="3">
<h1>Mike Tyler</h1>
PO Box 190387<br>
Hungry Horse, Mt 59919<br></font>
<img src="file:///c:/mike.jpg"/><br>
<a href=“biopage.html”>Read my Bio</a>
</p>
</body>
<html>
27
HTML - Fundamentals
Output
28
HTML – Fundamentals: Lists
Unordered list Ordered list
<li>strawberr
HTML – Fundamentals
Lists
Unordered list Ordered list
What is Definition
List?
30
HTML – Fundamentals: Heading
Renders text as a heading, the rendering depending on the level
of heading selected.
31
HTML – Fundamentals: Horizontal
Lines and Comments
Horizontal Line
The <hr /> tag is used to create an horizontal rule (line).
<p>This is a paragraph</p>
<hr/>
Comments
Comments are ignored by the browser and are not displayed.
Make the code readable and understandable
33
HTML – Fundamentals: Colors
Red Blue
Green
34
HTML
STYLE
35
HTML – Fundamentals: Style
Attribute
Purpose: To provide a common way to style all
HTML elements
It’s an HTML Global Attribute
Style attribute can be added to any HTML elements
HTML Style Examples
style="background-color : yellow"
style="font-size:10px"
style="font-family : Times"
style="text-align : center"
36
HTML – Fundamentals: Style
<html>
<body style="background-color : PowderBlue;">
<h1>Look! Styles and colors</h1>
<p style="font-family:verdana; color:red">
This text is in Verdana and red
</p>
<p style="font-family:times; color:green">
This text is in Times and green
</p>
<p style="font-size:30px">This text is 30 pixels high</p>
</body>
41
</html>
HTML – Fundamentals:
Style
<html>
<body style="background-color : PowderBlue;">
<h1>Look! Styles and colors</h1>
<p style="font-family:verdana; color:red">
This text is in Verdana and red
</p>
<p style="font-family:times; color:green">
This text is in Times and green
</p>
<p style="font-size:30px">This text is 30 pixels high</p>
</body>
</html>
38
Hyperlinks: Essence of Hypertext
HTML links are hyperlinks
Anchor Tag
<a href="url">link text</a>
39
More about Hyperlinks
<a href="https://www.w3schools.com/">Visit <a>
40
Hyperlinks - The Target Attribute
The target attribute specifies where to open the
linked document.
41
More about Hyperlinks
Absolute Paths (not recommended)
<a href=“e:/myWeb/html/intro.html”>
Target Attribute
<a href=“url” target=“_blank”>…</a>
42
More about Hyperlinks
Absolute Paths (not recommended)
<a href=“e:/myWeb/html/intro.html”>
Target Attribute
<a href=“url” target=“_blank”>…</a>
43
HTML – Fundamentals: Tables
<TABLE BORDER=“1”>
<CAPTION ALIGN="bottom">Class Grades</CAPTION>
<TR>
<TH>Student</TH>
<TH>Grade</TH>
</TR>
<TR>
<TD>Tom</TD>
<TD>B+</TD>
</TR>
<TR>
<TD>Sue</TD>
<TD>A-</TD>
</TR>
</TABLE>
44
HTML – Fundamentals: Table
Attributes
BORDER=value
CELLSPACING=value
CELLPADDING=value
WIDTH=value|percent
45
HTML – Fundamentals: Tables
<TABLE BORDER=1 WIDTH=“50%" CELLPADDING=“6” CELLSPACING=“2”
ALIGN="RIGHT">
<CAPTION ALIGN="bottom">Class Grades</CAPTION>
<TR>
<TH>Student</TH>
<TH>Grade</TH>
</TR>
<TR>
<TD>Tom</TD>
<TD>B+</TD>
</TR>
<TR>
<TD>Sue</TD>
<TD>A-</TD>
</TR>
50
</
HTML – Fundamentals: Tables
51
HTML – Fundamentals
<TABLE BORDER=1 WIDTH="50%" CELLPADDING=5 ALIGN="center">
<TR>
<TD colspan=2 align='center'>
<font color="red"><b>Student Grades</b></font>
</TD>
</TR>
<TR>
<TD><b>Student</b></TD>
<TD><b>Grade</b></TD>
</TR>
<TR>
<TD>Tom</TD>
<TD rowspan=2>A</TD>
</TR>
<TR>
<TD>Sue</TD>
</TR>
</TABLE>
48
HTML FORMS
What are Forms?
An HTML form is used to collect user input and send
it to the server for processing
1. action=“url” (required)
Specifies where to send the data when the Submit
button
is clicked
2. method=“GET" (default)
Specifies how to submit the data e.g. through GET or
POST
The Action Attribute
The action attribute defines the action to be performed when the form is
submitted.
Usually, the form data is sent to a file on the server when the user clicks on the
submit button.
52
The Method Attribute
<html>
<body>
</body>
</html>
53
Method = GET or POST
54
Method = GET vs POST
The <input> Element
The HTML <input> element is the most used form
element.
An <input> element can be displayed in many ways,
depending on the type attribute
56
Text Fields
57
Radio Buttons
58
Further Reading
W3Schools is a good and widely used resource to learn HTML
https://www.w3schools.com/html/html_tables.asp
https://www.w3schools.com/html/html_styles.asp
https://www.w3schools.com/html/html_lists.asp