WD-lecture1 HTML (2) (2)
WD-lecture1 HTML (2) (2)
Programming
Lecture 1: Introduction to HTML5: PART (1)
Dr Natheer Gharaibeh
1
In today’s lecture you will
learn ..
• What is HTML
2
What is HTML?
• Stands for Hyper Text Markup Language and it is
the most common language to write web pages.
3
How it all works ..
• HTML documents are stored in web
servers and are requested by clients (e.g.
web browsers) running on local
computers or smartphones.
4
HTML Tags
• A markup language is a set of markup tags:
• HTML tags normally (NOT always) come in pairs like <p> and
</p>.
• The first tag in a pair is the start tag (opening tag), the second
tag is the end tag (closing tag).
• The end tag is written like the start tag, but with a slash before
the tag name.
5
HTML Documents
• HTML documents are made up by HTML
elements.
<!doctype html>
<html>
• Must start with a document type declaration
tag:
<head>
<!DOCTYPE html> Document header related tags
</head>
• The HTML document itself begins with
<html>
and ends with </html>. <body>
• <head> tag contains meta data (i.e.
information about the document) and is placed Document body related tags
between the <html> tag and the <body> tag. </body>
• The visible part of the HTML document (i.e.
seen in web browsers) is between <body> and </html>
</body>.
6
Nested HTML Elements
•Most HTML elements can be nested (can contain other HTML
elements).
HTML Document Example
<html>
<body>
<p>This is my first paragraph.</p>
</body>
</html>
• To display a document correctly, the browser must know both type and version.
• The doctype declaration is not case sensitive. All cases are acceptable:
8
html, head and body
Elements
• The html element:
• encloses the head section and the body section.
9
Only the <body> area (the white area) is displayed by the browser.
10
The meta
Element
• <meta> Element
• is used to specify page description, keywords, author, and other metadata.
• meta data is used by browsers (how to display content), by search engines using (keywords), and
other web services.
• Example: Can be used to define keywords for search engines:
<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript”>
• Example: Can be used to define a description of your web page:
<meta name="description" content="Free Web tutorials on HTML and CSS">
• Example: Can be used to define the author of a page:
<meta name="author" content="Hege Refsnes”>
• Example: Can be used to define the character set used: To display an HTML page correctly, a
web browser must know the character set (character encoding) used in the page. UTF-8
(Unicode) is the default character encoding which covers almost all of the characters and
symbols in the world:
<meta charset=“UTF-8">
• Example:
<meta Can be used to content="30">
http-equiv="refresh“ refresh the document every 30 seconds:
11
HTML
Example • The DOCTYPE declaration defines
the document type to be HTML
• The browser does not display the HTML tags, but uses them to
determine how to display the document.
<!DOCTYPE html>
<html>
<head>
<titl
e>Pag
e
Title
</tit
le>
</head>
<body>
<h1>M
y
First 13
Headi
HTML Titles
• The HTML <title> element is meta data and it defines
the HTML document's title.
• It
provides a title for the page when it is added
to favorites.
• It
displays a title for the page in search engine
results. 14
HTML Headings
• Some text in an HTML5 document may be more important than other text.
• HTML5 provides six heading elements (h1 through h6) for specifying the relative
importance of information.
• Browsers automatically add some empty space (a margin) before and after each
heading.
• Use HTML headings for headings only. Don't use headings to make text BIG or
bold.
• Search engines use your headings to index the structure and content of your web
pages.
• Users skim your pages by its headings. It is important to use headings to show the
document structure. 15
HTML Headings
<body>
<h1>Level 1 Heading</h1>
<h2>Level 2 heading</h2>
<h3>Level 3 heading</h3>
<h4>Level 4 heading</h4>
<h5>Level 5 heading</h5>
<h6>Level 6 heading</h6>
</body>
16
HTML Paragraphs
• Help define the structure of a document.
• All the text placed between the <p> and </p> tags forms
one paragraph.
<body
>
<p>This is a
paragraph.</p>
<p>This is another
paragraph.</p>
</
body>
17
HTML Comments
• Comments can be inserted into the HTML code to make
it more readable and understandable.
Comments Syntax:
<!-- Write your comments here -->
19
HTML Line Breaks
• With HTML, you cannot change the output by adding extra spaces
or extra lines in your HTML code.
• The browser will remove extra spaces and extra lines when the page
is displayed. Any number of lines count as one line, and any
number of spaces count as one space.
• Use the <br /> tag if you want a line break (a new line)
without starting a new paragraph:
Example
<p>This is<br />a para<br />graph with line breaks</p>
• The <br /> element is an empty HTML element. It has no end tag.
20
The <pre>
Element
• The HTML <pre> element defines a block of pre-formatted text,
with structured spaces and lines.
• To display anything, with right spacing and line-breaks, you must wrap
the text in a <pre> element:
<pre>
</pre>
21
HTML Horizontal Rules
• The <hr /> tag creates a horizontal line in an HTML page.
<body>
<p>The hr tag defines a horizontal rule:</p>
<hr>
<p>This is a paragraph.</p>
<hr />
<p>This is a paragraph.</p>
<br />
<p>This is a paragraph.</p>
</body>
22
HTML
Style
• Every HTML element has a default style (background color
is white, text color is black, text-size is 12px)
• HTML uses elements like <b> and <i> for formatting output, like bold
or italic text.
25
DEMO
26
References
• http://www.w3schools.com
• Deitel & Deitel (2011): Internet and World Wide
Web How to Program, 5th Edition, Harvey &
Paul Deitel& Associates.
27