FEWD Topic 2 - Introduction To HTML 5
FEWD Topic 2 - Introduction To HTML 5
Topic 2:
Introduction to HTML5
Learning Outcomes
Unit Roadmap
Week Topic Week Topic
Overview of Web
1 Application Architecture 7 JavaScript - II
HTML
Introduction to HTML 5 Topic 2 - 2.6
HTML
• HTML stands for HyperText Markup Language.
• It is the standard markup language used for creating and structuring web pages
and web applications.
• HTML uses various elements and tags to define the content and layout of a
webpage.
What is hypertext?
What is markup language?
Introduction to HTML 5 Topic 2 - 2.7
Text-level Elements
• Text-level elements in HTML are used to structure and format the
text content within a web page.
• Allows application of specific meanings and styles to different parts
of the text.
• Effective use of these elements:
• Improves the accessibility of webpage
• Helps with search engine optimization (SEO)
• Provides a more meaningful user experience
• Commonly used text-level elements are described in following
slides.
Introduction to HTML 5 Topic 2 - 2.18
Text-level Elements
Text-level Elements
<p> (Paragraphs): <!DOCTYPE html>
<html>
• The <p> element defines a paragraph.
<head>
• It allows grouping together blocks of <title>My First Web Page</title>
text.
</head>
• Browsers add space before and after <body>
paragraphs to visually separate them. <p>This is a paragraph. It contains multiple
sentences and forms a coherent block of
text.</p>
<p> This is second paragraph.</p>
</body>
</html>
Introduction to HTML 5 Topic 2 - 2.21
Text-level Elements
<a> (Links):
• The <a> element creates hyperlinks.
• Allows users to navigate to other web pages or resources.
• The href attribute specifies the destination URL of the link.
<body>
<p>Check out my <a href="https://www.example.com">website</a> for more information.</p>
</body>
Introduction to HTML 5 Topic 2 - 2.22
Text-level Elements
<strong> and <em> (Emphasis):
• <strong> represents strong emphasis, often displayed as bold text by browsers.
• <em> represents emphasised text, typically displayed in italics by browsers.
• These elements add semantic meaning to the text, helping search engines and
assistive technologies.
<body>
<p><strong>Important:</strong> Please read the instructions carefully.</p>
<p>This quote is <em>very</em> inspiring.</p>
</body>
Introduction to HTML 5 Topic 2 - 2.23
Text-level Elements
<span> (Inline Container):
• The <span> element is an inline container.
• Allows to apply styles or add semantics to a specific section of text.
• Unlike block-level elements, <span> does not add line breaks before and after its
content.
<body>
<p>My bag is <span style="color:red">red</span> colour.</p>
</body>
Introduction to HTML 5 Topic 2 - 2.24
Text-level Elements
<abbr> (Abbreviation):
• The <abbr> element represents an abbreviation or acronym.
• Provides an additional information through a title attribute.
<body>
<p><abbr title="World Health Organization">WHO</abbr> provides health-related information.</p>
</body>
Introduction to HTML 5 Topic 2 - 2.25
Text-level Elements
<sub> and <sup> (Subscript and Superscript):
• <sub> is used for subscript text.
• Example: chemical formulas or mathematical expressions.
• <sup> is used for superscript text.
• Example: footnotes or exponentiation.
<body>
<p>H<sub>2</sub>O is the chemical formula for water.</p>
<p>2<sup>3</sup> = 8</p>
</body>
Introduction to HTML 5 Topic 2 - 2.26
Text-level Elements
<hr> (Horizontal Rule):
• The <hr> element inserts a horizontal line to separate content visually.
• It gives spacing between blocks.
• It is a self-closing element and does not have a closing tag.
<body>
<p>This paragraph is separated by a horizontal rule.</p>
<hr>
<p>Continuing with the next paragraph.</p>
</body>
Introduction to HTML 5 Topic 2 - 2.27
Text-level Elements
<blockquote> (Block Quote):
• The <blockquote> element represents a block of quoted content from another
source.
• Browsers typically indent and style blockquotes to distinguish them from regular
text.
<body>
<blockquote>
<p>"Be yourself; everyone else is already taken." - Oscar
Wilde</p>
</blockquote>
</body>
Introduction to HTML 5 Topic 2 - 2.28
Text-level Elements
<figure> and <figcaption> (Figure with Caption):
• The <figure> element:
• Represents content referenced from main content, such as images or videos.
• The <figcaption> element:
• Adds a caption or description to the content inside <figure>.
<body>
<figure>
<img src="image.jpg" alt="A beautiful landscape">
<figcaption>A breathtaking landscape.</figcaption>
</figure>
</body>
Introduction to HTML 5 Topic 2 - 2.29
HTML LISTS
Introduction to HTML 5 Topic 2 - 2.30
HTML Lists
Two types of lists:
• Unordered lists (bulleted lists)
– Created using the <ul> (unordered list) tag.
• Ordered lists (numbered lists)
– Created using the <ol> (ordered list) tag
• List items are represented by the <li> (list item) tag.
Introduction to HTML 5 Topic 2 - 2.31
HTML Lists
Unordered List (<ul>):
<body>
• A list of items without any specific order <ul>
or sequence.
<li>Item 1</li>
• Typically displayed as bullet points by <li>Item 2</li>
default. <li>Item 3</li>
• <ul> tag to create an unordered list </ul>
• Individual list items inside the <li> </body>
tags.
Introduction to HTML 5 Topic 2 - 2.32
HTML Lists
Ordered List (<ol>):
<body>
• Conversely, a list of items with a <ol>
specific order or sequence <li>Item 1</li>
• Typically displayed as bullet points by <li>Item 2</li>
default. <li>Item 3</li>
• <ol> tag to create an ordered list </ol>
</body>
• Individual list items inside the <li>
tags.
Introduction to HTML 5 Topic 2 - 2.33
HTML Lists
Nested Lists: <body>
• Lists can be nested inside <ul>
each other to create <li>Item 1</li>
hierarchical structures. <li>Item 2
<ul>
<li>Subitem 2.1</li>
<li>Subitem 2.2</li>
</ul>
</li>
<li>Item 3</li>
</ul>
</body>
Introduction to HTML 5 Topic 2 - 2.34
HTML FORMS
Introduction to HTML 5 Topic 2 - 2.35
HTML Forms
Think for a website where you • Approach for users to submit data
use form before and discuss to a web server for processing.
the various types of form from
different websites. • Essential for various interactive
elements:
• Contact forms
• Login pages
• Search bars
Introduction to HTML 5 Topic 2 - 2.36
HTML Forms
• The <form> element is used to create an HTML form.
• Form elements:
• Input fields
• Buttons
• Checkboxes
• Radio buttons
• The action attribute specifies the URL where the form data will be
sent upon submission.
• The method attribute defines the HTTP method used for the form
submission (e.g., "GET" or "POST").
Introduction to HTML 5 Topic 2 - 2.37
HTML Forms
<input>:
• The <input> element represents various form controls like text input, radio
buttons, checkboxes, buttons, etc.
• The type attribute defines the type of input control to be displayed.
• The name attribute is used to identify the input field when the form is submitted.
HTML Forms
<textarea>:
• The <textarea> element creates a multi-line text input area for longer
text entries.
• The name attribute is used to identify the textarea when the form is
submitted.
<form action="/submit" method="post">
<label for="message">Message:</label>
<textarea id="message" name="message"
rows="4" cols="50"></textarea>
<input type="submit" value="Submit">
</form>
Introduction to HTML 5 Topic 2 - 2.39
HTML Forms
<select> and <option>:
• The <select> element creates a dropdown list, and <option> elements define the
individual options in the list.
• The name attribute is used to identify the select field when the form is submitted.
<form action="/submit" method="post">
<label for="country">Country:</label>
<select id="country" name="country">
<option value="USA">United States</option>
<option value="UK">United Kingdom</option>
<option value="Canada">Canada</option>
</select>
<input type="submit" value="Submit">
</form>
Introduction to HTML 5 Topic 2 - 2.40
HTML Forms
<button>:
• The <button> element represents a clickable button within the form.
• It can be used for various purposes, such as submitting the form, triggering
JavaScript functions, etc.
HTML Forms
<fieldset> and <legend>: <form action="/submit" method="post">
<fieldset>
• The <fieldset> element groups
related form elements together and <legend>Contact Information</legend>
creates a visual boundary around <label for="name">Name:</label>
them. <input type="text" id="name" name="name">
<label for="email">Email:</label>
• The <legend> element provides a <input type="email" id="email" name="email">
caption or label for the fieldset.
</fieldset>
<input type="submit" value="Submit">
</form>
Introduction to HTML 5 Topic 2 - 2.42
HTML Forms
<input type="radio"> and <input <form action="/submit" method="post">
type="checkbox">: <label for="male">Male</label>
• The <input type="radio"> element <input type="radio" id="male" name="gender" value="male">
represents a radio button, allowing users
<label for="female">Female</label>
to select one option from a group of
options. <input type="radio" id="female" name="gender"
value="female">
• The <input type="checkbox"> element
represents a checkbox, allowing users to <br>
select one or more options from a group <label for="subscribe">Subscribe to Newsletter</label>
of options. <input type="checkbox" id="subscribe" name="newsletter"
value="subscribe">
<input type="submit" value="Submit">
</form>
Introduction to HTML 5 Topic 2 - 2.43
Quiz - 1
1. What is the correct order of elements in a basic HTML document structure?
A) <body>, <head>, <html>
B) <head>, <html>, <body>
C) <html>, <head>, <body>
D) <html>, <body>, <head>
2. Which HTML element is used to define the metadata of the document, such as its title and character set?
A) <body>
B) <header>
C) <meta>
D) <head>
Quiz - 2
1. Which element is used to define emphasized text in HTML?
A) <strong>
B) <em>
C) <mark>
D) <i>
3. Which HTML element is used to define a part of text in an alternate voice or mood?
A) <blockquote>
B) <cite>
C) <q>
D) <s>
Introduction to HTML 5 Topic 2 - 2.48
Quiz - 3
1. What is the purpose of the <form> element in HTML?
A) To create a searchable database
B) To display user inputs
C) To collect user inputs
D) To format document sections
2. Which attribute specifies the method the form data should be sent to the server?
A) method
B) action
C) type
D) enctype
3. What type of form input is used to submit the form to the server?
A) <input type="text">
B) <input type="submit">
C) <input type="button">
D) <input type="checkbox">
Introduction to HTML 5 Topic 2 - 2.49
References
Introduction to HTML:
Mozilla Developer Network (MDN). (n.d.). Introduction to HTML. Available at:
https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML
Any Questions?