Lecture 2 - HTML 2
Lecture 2 - HTML 2
§ Evolution of HTML
§ HTML syntax & tags
§ Character Entities
§ Meta data
§ Images
§ Links
§ Lists
§ Tables
§ Forms – a first look
§ <audio> & <video> element
§ <time> element
2
§ Tables are defined with the <table> tag
§ Captions are given with <caption></caption>
§ Defined row-by-row not column-by-column
§ The table size is not given, it is calculated
3
4
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
5
2-Table1.html
<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>
§ Merging cells
6
colspan and rowspan
2-Table2.html
<table border="1">
<tr >
<td colspan = 4>This cell spans all 4 col.</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
<td>row 2, cell 3</td>
<td>row 2, cell 4</td>
</tr>
…
<tr>
<td>row 3, cell 1</td>
<td rowspan = 2>row 3 cell 2 spans 2 rows</td>
<td colspan = 2>row 3 cell 3 spans 2 col.</td>
</tr>
<tr>
<td>row 4 cell 1</td>
<td>row 4 cell 3</td>
<td>row 4 cell 4</td>
</tr>
</table>
8
§ Work out the html code for this table
9
Work out the html code for this table
Hint: First line is done with <caption> tag and will need the <th>
tag and <em> for italic 10
§ Evolution of HTML
§ HTML syntax & tags
§ Character Entities
§ Meta data
§ Images
§ Links
§ Lists
§ Tables
§ Forms – a first look
§ <audio> & <video> element
§ <time> element
11
§ Allow user interaction
§ To make them do
something we need a
programming
language like
JavaScript
§ <form></form> is
used to transmit
information to the
server
12
form tag is a container for form elements
o Text boxes
o Password boxes
o Text areas
o Select lists
o Check boxes
o Radio buttons
o Buttons
o Labels
13
§ <form> </form> tags define the form as a part of the page
§ How to use:
<form action = ″″>
</form>
14
15
§ text field/box with a label
<label>User Name</label>
<input type ="text" name="usrNm" /> or
<input type ="text" name ="usrNm" value="Enter your
name"/>
16
§ password field with a label
<p>
<label>Password</label>
<input type = "password" name="usrNm"/>(6 to 20
characters))
</p>
17
§ textarea with a label
<p>
<label>Address:</label>
<textarea name ="address” rows = "10” columns = "20">
</textarea>
</p>
18
§ Drop Down Menu
<form action="">
<form action="">
...
<input type = "submit" value = "Submit" />
<input type = "reset" value = "Reset" />
...
</form>
22
§ Example of Coffee2.html 23
§ <fieldset> is used to group several controls as well as labels.
§ Example:
<form>
<fieldset>
<legend>Choose your favorite food</legend>
<label> <input type="radio" name="Pizza"/>Pizza</label><br/>
<label><input type="radio" name="sandwich"/>Sandwich</label><br/>
<label><input type="radio" name="Fish and Chips"/>Fish and Chips</label>
</fieldset>
</form>
24
§ Evolution of HTML
§ HTML syntax & tags
§ Character Entities
§ Meta data
§ Images
§ Links
§ Lists
§ Tables
§ Forms – a first look
§ <audio> & <video> element
§ <time> element
25
§ Prior to HTML5, a plug-in was required to play sound while a
document was being displayed such as Flash or Microsoft’s Media
Player
<audio attributes>
<source src = "filename1" >
...
<source src = "filenamen" >
Your browser does not support the audio element
</audio>
§ Browser chooses the first audio file it can play and skips the rest of the
content of audio element content
26
§ Different browsers have different audio capabilities
http://www.w3schools.com/html/html5_audio.asp 28
<!DOCTYPE html>
<!– audio.html - Test the audio element -->
<html lang = "en" >
<head>
<title> Test audio element </title>
<meta charset = "utf-8" />
</head>
<body>
This is a test of the audio element
<audio controls= "controls" >
<source src = "nineoneone.ogg" />
<source src = "nineoneone.wav" />
<source src = "nineoneone.mp3" />
Your browser does not support the audio element
</audio>
</body>
29
Audio.html
</html>
§ Just like <audio> prior to HTML5, there was no standard way to play
video clips while a document was being displayed
§ Browser chooses the first video file it can play and skips the content; if
none, it displays the content
30
§ Different browsers have different video capabilities
32
<!DOCTYPE html>
<!-- testvideo.html test the video element -->
<html lang = "en">
<head>
<meta charset = "UTF-8" />
<title> test video element </title>
</head>
<body>
This is a test of the video element.....
<video width = "600" height = "500"
controls= "contrpls" loop= "loop" muted= "muted"
poster = " logoc.png" >
<source src = "NorskTippingKebab.mp4" />
<source src = "NorskTippingKebab.ogv" />
<source src = "NorskTippingKebab.webm" />
Your browser does not support the video element
</video>
</body>
33
</html> Video.html
§ Evolution of HTML
§ HTML syntax & tags
§ Character Entities
§ Meta data
§ Images
§ Links
§ Lists
§ Tables
§ Forms – a first look
§ <audio> & <video> element
§ <time> element
34
§ The <time> tag defines a specific time (or datetime).
§ The datetime attribute represent a machine-readable format of
the <time> element
<!DOCTYPE html>
<html>
<body>
<h1>The time element</h1>
<p>Open from <time>10:00</time> to <time>21:00</time>
every weekday.</p>
<p>I have a class on <time datetime="2021-03-15 9:00">
St. Patrick's Day </time>.</p>
</body>
</html>
35 Time.html
§ Browsers are designed to be robust and deal with many
errors in web pages
36
§ W3Schools HTML Reference
§ Don't worry, you will not have to memorize all these HTML tags,
attributes, etc...
your memory
37
§ Design a form
38
§ Design a form
39