HTML5 - Eng
HTML5 - Eng
UP Web
AU: 2022/2023
PLAN
How does it work?
First Example
HTML Tags
Comments
HTML document
Main tags
2
Objectives
3
How it works?
Client Server
The client requests a page from
the server
4
HTML: Presentation and Versions
• HTML is used to create and compose the content of a web page and its structure.
Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element 5
HTML: Presentation and Versions
6
First Example
File:
index.html
7
HTML Tags
• Anatomy of an HTML element
Element
Content
<p>Hello World!</p>
8
HTML Tags
• Nesting elements
Example
Result
9
HTML Tags
• Empty elements
Example:
<img src="image.jpg" alt="logo">
<br>
<hr>
10
HTML Tags
• Attributes
<a href ="www.esprit.tn">Site Esprit</a>
Attribute Value
name
Attribute Value
name
Result:
12
Comments
13
HTML document
<!DOCTYPE html>
14
HTML document
<html> … </html>
<head> … </head>
• Acts as a container for any information needed for the page but is not part of
the displayed content: meta tags (keywords, description, author …), page title
and links to CSS and JS files.
16
HTML document
<title> … </title>
• defines the page title.
• This title will appear on the tab
when the page is loaded.
17
HTML document
<body> … </body>
• Contains the document body.
• The content will be seen by visitors
(text, image, sound…)
18
Tags: Title
• There are 6 title levels:
<h1> - <h6>
• By default the title tag adds an empty line.
• Generally, 3 to 4 levels are enough.
19
Tags: Paragraph
Tag <p>…</p>
• Is preceded and followed by a line break.
• Eliminates redundant spaces and line breaks.
20
Tags: List
• Ordered list <ol>…</ol>
• Unordered list <ul>…</ul>
• Description list <dl>…</dl>
21
Tags: Image
• We use the tag: <img>
• Example:
<img src="assets/images/logo.jpg" alt="Esprit Logo"
height="100" width="150">
Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element#image_and_multimedia 22
Tags: Link
• We use the tag: <a>
Example: <a href= "link target" > text </a>
• There are 4 different cases:
– A link to a website or a page of site.
• <a href= "https://www.google.com" > google </a>
– A link to a downloadable file.
• <a href= "link target" > download </a>
– A link to an email or phone address.
• <a href= "mailto:[email protected]"> Contact us</a>
• <a href= "tel:+21698765432"> Contact us</a>
– A link to a target on the same page.
• <h1 id="anchor"> Contact </h1>
• <a href="#anchor"> Jump to Contact </a>
23
Tags: Formatting
• These tags can be contained in a paragraph.
• More tags to discover <strong>, <mark>, <em>, <abbr>, <cite>, <q>, <code>
24
Tags: Structure
• Without a semantic meaning:
– <div> … </div>
– <span> … </span>
• With a semantic meaning:
– <header> … </header>
– <article> … </article>
– <nav> … </nav>
– <aside> … </aside>
– <footer> … </footer>
– <section> … </section>
25
Tags: Table
• We use the tag:
<table> … </table>
• The table is then constructed line by line:
<tr> … </tr>
• The row contains cells:
<td> … </td>
26
Tags: Table
• We can add a header:
<th> … </th>
27
Tags: Table
• We can use the border attribute
<table border = "1">
But in HTML5, its usage is obsolete.
28
Tags: Table
Advanced concepts
• Horizontal merge – Column merge
<td colspan = "2">
29
Tags: Table
Advanced concepts
• We use the tag
<caption> … </caption>
to add a title to the table.
It can be added after the opening
of the table tag or just before
closing it.
30
Tags: Form
• We use the tag
<form> … </form>
– Method: The HTTP method used to send the data. It is either GET or
POST.
31
Tags: Form
The components of a form
32
Tags: Form
The components of a form
34
Tags: Form
The components of a form
35
Tags: Form
The components of a form
• Attributes:
– autocomplete
– autofocus
– checked, selected
– disabled, readonly
– maxlength, minlength
36
Tags: Form
The components of a form
• Examples
– checked / selected
37
Tags: Form
The components of a form
• Examples
– checked / selected
38
Tags: Form
The components of a form
• Examples
– disabled / readonly
39
Tags: Form
The components of a form
• Examples
– Max / Min / Step
40
Tags: Form
The components of a form
• Examples
– Maxlength / Minlength
41
Tags: Form
The components of a form
• Examples
– placeholder
42
Tags: Form
The components of a form
• Examples
– pattern
43
General Remarks
• Many other tags already exist + new ones added in HTML 5.
• There are few rules to follow when placing the tags (i.e. no <li> on its own).
• There are some validators, you can use them. https://validator.w3.org/
• In general, spaces are ignored. They must be used to make the code of the
page readable.
• The default style is quite rudimentary. This style can be modified using CSS
properties.
44
Thank you for your attention
45