Chapter 2 - HTML
Chapter 2 - HTML
Instructor: Melaku M.
Web Programming
➢ Client-side scripting
➢ Server-side scripting
Introduction to HTML
Introduction to HTML
❖HTML (Hypertext Markup Language) is the standard markup language used
to create web pages and web application.
✓Markup defines the text document within tags to structure the web pages.
❖It is often assisted by technologies such as Cascading Style Sheets (CSS) and
scripting languages such as JavaScript.
❖In HTML, hyperlinks are created using the anchor tag <a>
Markup Language
❖Markup language is a system for annotating a document in a way that is
syntactically distinguishable from the text. The annotations specify how the text
should be structured, formatted, or presented. The markup symbols/codes tells
web browsers how to display a webpage’s words and images.
• Formatting: They specify how the content should be presented, including font size, style,
color, and alignment.
• Presentation: control the layout and appearance of a document, such as margins, spacing,.
HTML elements and tags
❖HTML elements are the building blocks of web pages. They define different parts of
the webpage such as headings, paragraphs, lists, images, links, table. form and more.
❖Tags are used to define the beginning and end of an element, while elements consist of
the opening tag, content, and closing tag.
❖In other words, tags are the markers that define where an element begins and ends,
while elements encompass the entire structure including the content contained within the
tags.
HTML elements
❖The HTML element is defined by a start tag, some content, and an end tag:
❖The HTML element is everything from the start tag to the end tag:
The basic
structure of
an HTML
page is here
Web Browsers
❖The purpose of a web browser (Chrome, Edge, Firefox, Safari) is to read
HTML documents and display them correctly.
❖A browser does not display the HTML tags, but uses them to determine how to
display the document:
HTML tags
❖HTML tags are like keywords which defines that how web browser
will format and display the content. With the help of tags, a web
browser can distinguish between an HTML content and a simple
content.
❖All HTML tags must enclosed within < > these brackets.
❖If you have used an open tag <tag>, then you must use a close tag
</tag> (except some tags)
❖Syntax: <tag> content </tag>
A Simple HTML Document
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
</body>
</html>
1. Basic HTML tags (HTML, HEAD, BODY,TITLE)
❖<!DOCTYPE html>: This tag specifies the document type as HTML5. and
helps browsers to display web pages correctly.
❖<html>: This tag defines the root of the HTML document/page.
❖<head>: This tag contains metadata about the document/page, Elements within
the head aren’t visible on the front end of a webpage. Such as <style>, <title> ,
<script>, <meta>, <link>
❖<title>: This tag sets the title of the webpage.
❖<body>: This tag defines the webpages/documents body, and is a container for
all the visible contents, such as headings, paragraphs, images,, tables, lists, etc.
❖<p>: This tag defines a paragraph.
2. HTML Meta tags
❖HTML meta tags are special <HTML>
<head>
sections within the <head>
<meta charset="UTF-8">
section of an HTML document
<meta name="viewport"
that provide metadata about content="width=device-width, initial-
the webpage. scale=1.0">
<meta name="description"
❖This metadata is used by search content=“write this page description.">
engines, browsers, and other <title>My Webpage</title>
applications to understand the </head>
❖These comments are not visible on the rendered webpage but are present in the
source code, making it easier for developers to collaborate, debug, and maintain
clean code.
❖In HTML, links are created using the <a> tag, and the destination of the link is
specified using the href attribute
❖Syntax:
❖Example:
❖Subscript Tag <sub>: Used to display text as subscript (below the baseline).
H<sub>2</sub>O
❖Preformatted Text Tag <pre>: Used to preserve whitespace and line breaks.
❖Horizontal Rule Tag <hr>: Used to create a horizontal rule. Example <hr>
5. HTML Text Formatting tags
❖Inline Quote: <q>:
❖Break tags <br>: forces the content that follows it to start on a new line.
5. HTML Text Formatting tags
❖<abbr> tag in HTML is used to define an abbreviation or acronym
<abbr title="Hypertext Markup Language">HTML</abbr>
<p>The <abbr title="National Aeronautics and Space Administration">NASA</abbr>
was established in 1958.</p>
<ul> <ol>
<li>Item 1</li> <li>First item</li>
<li>Item 2</li> <li>Second item</li>
</ul> </ol>
❖HTML forms are used to collect user input from a web page. They can include
various types of form controls, allowing for various type of data to be submitted.
❖Audio: To embed audio files, use the <audio> tag. This tag supports various
audio formats like MP3, WAV, and OGG. You can also include controls for
playback.
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
10. Inserting Multimedia in HTML
❖Video: To embed video files, use the <video> tag. Like the audio tag, it supports
various formats and can include controls.
</video>
controls: Adds video playback controls to the element.
<source>: Specifies the source of the video file.
type: Specifies the MIME type of the video file.
10. Inserting Multimedia in HTML
❖Embedding YouTube Videos: To embed a YouTube video, you can use the
<iframe> tag. You’ll need the embed link from the YouTube video.
</iframe>
Complete Example: Inserting Multimedia in HTML
<html lang="en">
<head>
<title>Multimedia Example</title>
</head>
<body>
<h1>Multimedia in HTML</h1>
<h2>Image</h2>
<img src="https://via.placeholder.com/300" alt="Placeholder Image"
title="This is a placeholder image">
<h2>Audio</h2>
<audio controls>
<source src="https://www.mp3.com//Sound.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
Complete Example: Inserting Multimedia in HTML
<h2>Video</h2>
<video width="320" height="240" controls>
<source src="https://www.w3schools.com/html/mov_bbb.mp4"
type="video/mp4">
Your browser does not support the video tag.
</video>
<h2>YouTube Video</h2>
<iframe width="560" height="315"
src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0"
allowfullscreen></iframe>
</body>
</html>
11. HTML Graphics
❖ Graphics are representations used to make web-page or applications visually
appealing and also for improving user experience and user interaction.
❖Usually, the following technologies are used in web graphics with HTML5:
Canvas, SVG WebCGM, CSS, etc.
1. HTML Canvas Graphics
❖The HTML <canvas> element is used to draw graphics, via JavaScript.
❖The <canvas> element is only a container for graphics. You must use
JavaScript to actually draw the graphics.
❖Canvas has several methods for drawing paths, boxes, circles, text, and adding
images. It can be used for animation, game graphics, data visualization, photo
manipulation, and etc.
2. HTML SVG
❖SVG stands for Scalable Vector Graphics
❖ SVG graphics do not lose any quality when zoomed or resized, and every
element and attribute in SVG files can be animated.
❖SVG integrates with other standards, such as CSS, DOM, XSL and JavaScript