Professional Documents
Culture Documents
3
Introduction
HTML Tags
• HTML tags are keywords (tag names) surrounded by angle
brackets:
<tagname>content goes here...</tagname>
• HTML tags normally come in pairs like <p> and </p>.
• The first tag in a pair is the start tag, the second tag is the end
tag.
• The end tag is written like the start tag, but with a forward
slash inserted before the tag name.
• The start tag is also called the opening tag, and the end tag
the closing tag.
Introduction
Web Browsers
• The purpose of a web browser (Chrome, IE, Firefox, Safari) is to
read HTML documents and display them.
• The browser does not display the HTML tags, but uses them to
determine how to display the document:
Activity
feps.edu.eg > Crtl + U to view page source
Activity
feps.edu.eg > Crtl + U to view page source
HTML!
Introduction
<head>
e
pl
Only the <body>
m
<title> Page Title </title>
a
section (the white
Ex
area) is displayed in a
st
</head>
ir
browser.
rF
<body>
ou
to
<h1> This is a heading </h1>
kc
Ba
<p> This is a paragraph </p>
</body>
</html>
Introduction
e
pl
m
• The <!DOCTYPE> declaration is not an HTML
a
Ex
tag; it is an instruction to the web browser
st
ir
rF
about what version of HTML the page is
ou
written in.
to
kc
<!DOCTYPEishtml>
• The doctype declaration not case sensitive.
Ba
All cases are acceptable:
<!doctype HTML>
Introduction
HTML Editors
• Web pages can be created and modified by using professional
HTML editors.
• However, for learning HTML we recommend a simple text editor
like Notepad (PC) or TextEdit (Mac).
• Using a simple text editor is a good way to learn HTML.
• Follow the next section to create your first web page with
Notepad.
13
Starting with HTML
<!DOCTYPE html>
<html>
<body> 3
<h1>My First Heading</h1>
1
In computers, encoding is the
process of putting a sequence of
6
You can use either .htm or .html as file 7
extension. There is no difference, it is
up to you.
Starting with HTML
17
HTML Elements
<p>This is a
paragraph </p>
<p>This is a
paragraph </p>
</body>
</html>
HTML Elements
</body>
</html>
Basic HTML Tags
23
HTML Headings Note: Use HTML
headings for headings
only. Don't use
headings to make
Headings are important in HTML documents.
text BIG or bold.
Headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least
important heading.
Browsers automatically add some white space (a margin) before and
after a heading.
Headings Are Important:
• Search engines use the 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.
• <h1> headings should be used for main headings, followed by <h2> headings,
then the less important <h3>, and so on.
HTML Headings
The <hr> tag defines a thematic break in an HTML page, and is most
often displayed as a horizontal rule.
The <hr> element is used to separate content (or define a change) in an
HTML page:
HTML Text Displayed in Browser
<h1>This is heading 1</h1> This is heading 1
<p>This is some text.</p>
<hr> This is some text.
</body>
</html>
HTML Paragraphs
</body>
</html> Note: Browsers
automatically add some
white space (a margin)
before and after a
paragraph.
HTML Paragraphs
HTML Text Displayed in Browser
<p> This paragraph contains a lot of lines in the source code, but
This paragraph the browser ignores it.
contains a lot of lines
in the source code, This paragraph contains a lot of spaces in the source code,
but the browser but the browser ignores it.
ignores it.
</p> The number of lines in a paragraph depends on the size of the
browser window. If you resize the browser window, the
<p> number of lines in this paragraph will change.
This paragraph
contains a lot of spaces
in the source code, Note: You cannot be sure how HTML will be displayed.
but the browser Large or small screens, and resized windows will create
ignores it. different results.
</p> With HTML, you cannot change the output by adding
extra spaces or extra lines in your HTML code.
<p>
The browser will remove any extra spaces and extra lines
The number of lines in a paragraph depends on the size of the
browser window. If you resize the browser window, the when the page is displayed.
number of lines in this paragraph will change. </p>
HTML Line Breaks
<p>This is<br>a
paragraph<br>with line breaks</p>
</body>
</html>
The HTML <pre> Element
My Bonnie lies over the sea. My Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
My Bonnie lies over the ocean.
34
HTML Attributes
</body>
</html>
HTML Attributes
Size Attributes
• HTML images are defined with the <img> tag.
• The filename of the source (src), and the size of the image
(width and height) are all provided as attributes:
<img src="w3schools.jpg" width="104" height="142">
HTML Attributes
You will learn more about images, links and the <a> tag later in this
tutorial.
HTML Attributes
<p><a href=http://www.w3.org/>W3C</a>
is a link to a website on the World Wide
Web.</p>
</body>
HTML Styles
40
HTML Styles
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Styles
</body>
</html>
HTML Styles
HTML Fonts
• The font-family property defines the font to be used for an HTML
element:
HTML Text Displayed in Browser
<!DOCTYPE html>
<html> This is a heading
<body> This is a paragraph.
<h1 style="font-family :verdana;">This is a
heading</h1>
<p style="font-family :courier;">This is a
paragraph.</p>
</body>
</html>
HTML Styles
</body>
</html>
HTML Styles
</body>
</html>
HTML Text Formatting
47
HTML Text Formatting
</body>
</html>
HTML Text Formatting
</body>
</html>
HTML Text Formatting
<p><u>This text is
underlined.</u></p>
</body>
</html>
HTML Text Formatting
</body>
</html>
HTML Text Formatting
<h2>HTML
Formatting
<mark>Marked</mark>
Formatting</h2>
</body>
</html>
HTML Text Formatting
<p>This is
<sub>subscripted</sub> text.</p>
</body>
</html>
HTML Text Formatting
<p>This is
<sup>superscripted</sup>
text.</p>
</body>
</html>
HTML Comments – Quotes
--------------------------Abbreviations
56
HTML Comments
The HTML <abbr> element defines an abbreviation or an acronym. When you hover the mouse on the
word in the browsing view you will see the details of the acronym.
60
HTML Colors
In HTML, a color can be specified by using a color name, an RGB value, or
a HEX value.
Color Names
HTML
• In HTML, a color can be specifiedText Displayed
by using inname:
a color Browser
<h2 style="background-color :red">
Background-color set by using red </h2>
62
HTML Divisions
The <div> tag in HTML is a tag that defines a section or division of a page
on which you can apply certain settings (styling or formatting) without
having to put that section in a paragraph or header form.
HTML Text Displayed in Browser
<!DOCTYPE html>
This is a paragraph
<html>
<body>
<h3>
This is a paragraph. </h3>
<div style="background-color: This is a part of the page with
black; color: white; padding :
20px;"> special setting
This is a part of the page with
special setting.
</div>
</body>
</html>
HTML Links
64
HTML Links
HTML links are hyperlinks.
Links are found in nearly all web pages. Note: A link does not
have to be text. It can
Links allow users to click their way from page to page.
be an image or any
other HTML element.
In HTML, links are defined with the <a> tag:
<a href="url">link text</a>
“a” stands for Anchor and “href” stands for Hypertext Reference.
HTML Text Displayed in Browser
<!DOCTYPE html> Visit our HTML tutorial
<html>
<body>
<p> <a
href="http://www.w3schools.com/html/">Vi
sit our HTML tutorial</a> </p>
</body>
HTML Links
Local Links
• The previous example used an absolute URL (A full web address).
• A local link (link to the same web site) is specified with a relative URL
(without http://www....).
HTML Text Displayed in Browser
<!DOCTYPE html> HTML Images is a link to a page on this
<html> website.
<body> W3C is a link to a website on the World
<p><a Wide Web.
href="html_images.asp">HTML
Images</a> is a link to a page on this
website.</p>
<p><a
href="http://www.w3.org/">W3C</a>
is a link to a website on the World
Wide Web.</p>
HTML Links
HTML Links: Colors
• When you move the mouse over a link, two things will normally
happen:
• The mouse arrow will turn into a little hand.
• The color of the link element will change.
</body>
HTML Links
Mailto Link
• It follows the same coding scheme as the hypertext link before.
• <a href="mailto:nahed.taha@feps.edu.eg">Click Here To Write Me</a>
• Notice it's the same format as a link except in a link you write "mailto:"
in place of the http:// and your e-mail address in place of the page
address
• NO SPACE between the colon and the e-mail
HTML address in Browser
Text Displayed
<address> Written by Nahed Taha.
Written by <a Visit us at:
href="mailto:nahed.taha@feps.edu.eg">Nahed feps.edu.eg
Taha</a>.<br> 35 Faisal, Giza
Visit us at:<br> Egypt
feps.edu.eg<br>
35 Faisal, Giza<br>
Egypt
</address>
HTML Links
HTML Links: Create a Bookmark
• HTML bookmarks are used to allow readers to jump to specific parts of a Web page.
• Bookmarks can be useful if your webpage is very long.
• To make a bookmark, you must first create the bookmark, and then add a link to it.
• When the link is clicked, the page will scroll to the location with the bookmark.
First, create a bookmark with the id attribute:
<h2 id="tips">Useful Tips Section</h2>
Then, add a link to the bookmark ("Useful Tips Section"), from within the same page:
<a href="#tips">Visit the Useful Tips Section</a>
Or, add a link to the bookmark ("Useful Tips Section"), from another page:
<a href="html_tips.html#tips">Visit the Useful Tips Section</a>
HTML Links
HTML Text Displayed in Browser
<body>
Jump to Chapter 4
<p><a href="#C4">Jump to Chapter Chapter 1
4</a></p>
This chapter explains ba bla bla
<h2>Chapter 1</h2> Chapter 2
<p>This chapter explains ba bla bla</p>
This chapter explains ba bla bla
<h2>Chapter 2</h2> Chapter 3
<p>This chapter explains ba bla bla</p>
This chapter explains ba bla bla
<h2>Chapter 3</h2> Chapter 4
<p>This chapter explains ba bla bla</p>
This chapter explains ba bla bla
<h2 id="C4">Chapter 4</h2>
<p>This chapter explains ba bla bla</p>
</body>
HTML Images
74
HTML Images
<h2>Spectacular Mountain</h2>
<img src="pic_mountain.jpg" alt="Mountain
View" style="width: 304px;height: 228px;">
</body>
</html>
HTML Images
The alt Attribute
• The alt attribute provides an alternate text for an image, if the user for
some reason cannot view it (because of slow connection, an error in the
src attribute, or if the user uses a screen reader).
• If a browser cannot find an image, it will display the value of the alt
attribute:
HTML Text Displayed in Browser
HTML
• Alternatively, Text Displayed in
you can use the width and height attributes. Here, the
Browser
values are specified in pixels by default:
<img src="html5.gif" alt="HTML5
Icon" width="128" height="128">
HTML Images
Width and Height, or Style?
• Both the width, height, and style attributes are valid in HTML5.
• However, we suggest using the style attribute. It prevents internal or external
styles sheets from changing the original size of images:
HTML Text Displayed in Browser
<style> It is better to use the style attribute
img { (instead of the width and height
width: 100%; attributes), because it prevents
} internal or external styles sheets to
</style> change the original size of an image:
<body>
<p>It is better to use the style attribute (instead of the width and
height attributes), because it prevents
internal or external styles sheets to change the original size of an
image:</p>
<img
src="C:\Users\NahedTaha\Desktop\HTML\images/ht
ml5.gif" alt="HTML5 Icon" style="width:
128px;height: 128px;">
</body>
HTML Images
Animated Images
• The GIF standard allows animated images:
HTML Text Displayed in Browser
<body> The GIF standard allows
moving images.
<p>The GIF standard allows moving
images.</p>
</body>
Note that the syntax
of inserting animated
images is no
different from non-
animated images.
HTML Images
Using an Image as a Link
• To use an image as a link, simply nest the <img> tag inside the <a> tag:
HTML Text Displayed in Browser
<p>The image is a link. You can click on The image is a link. You can
it.</p> click on it.
<a
href="https://en.wikipedia.org/wiki/Smiley"> Add "border:0;" to prevent IE9
<img src="smiley.gif" alt="HTML tutorial" (and earlier) from displaying a
style="width:42px;height:42px;border:0;"> border around the image.
</a>
Note that border:0; is
<p>Add "border:0;" to prevent IE9 (and added to prevent IE9
earlier) from displaying a border around the (and earlier) from
image.</p> displaying a border
around the image
(when the image is a
link).
HTML Lists
83
HTML Lists
Unordered HTML List
• An unordered list starts with the <ul> tag. Each list item starts with the
<li> tag.
• The
HTMLlist items will be marked with bullets
Text Displayed (small black circles) by default:
in Browser
<!DOCTYPE html>
<html> An unordered HTML list
<body> • Coffee
<h2>An unordered HTML
• Tea
list</h2> • Milk
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
HTML Lists
Ordered HTML List
• An ordered list starts with the <ol> tag. Each list item starts with the
<li> tag.
• The
HTMLlist items will be marked with numbers
Text Displayed by default:
in Browser
<!DOCTYPE html>
<html> An ordered HTML list
<body> 1. Coffee
<h2>An ordered HTML
2. Tea
list</h2> 3. Milk
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
HTML Lists
Ordered HTML List: The Type Attribute
• The type attribute of the <ol> tag, defines the type of the list item
marker:
Type Description
type="1" The list items will be numbered with numbers
(default)
type="A" The list items will be numbered with uppercase
letters
type="a" The list items will be numbered with lowercase
letters
type="I" The list items will be numbered with uppercase
roman numbers
type="i" The list items will be numbered with lowercase
roman numbers
HTML Lists
HTML Text Displayed in Browser
<!DOCTYPE html>
<html> Ordered List with Numbers
<body> 1. Coffee
<h2>Ordered List with
2. Tea
Numbers</h2> 3. Milk
<ol type="1">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
HTML Lists
HTML Text Displayed in Browser
<!DOCTYPE html>
<html> Ordered List with Letters
<body> A. Coffee
<h2>Ordered List with
B. Tea
Letters</h2> C. Milk
<ol type="A">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
HTML Lists
HTML Text Displayed in Browser
<!DOCTYPE html>
<html> Ordered List with Lowercase
<body> Letters
<h2>Ordered List with • Coffee
Lowercase Letters</h2> • Tea
o Black tea
<ol type="a"> o Green tea
<li>Coffee</li>
<li>Tea</li> • Milk
<li>Milk</li>
</ol>
</body>
</html>
HTML Lists
HTML Text Displayed in Browser
<!DOCTYPE html>
<html> Ordered List with Roman
<body> Numbers
<h2>Ordered List with Roman I. Coffee
Numbers</h2> II. Tea
III. Milk
<ol type="I">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
HTML Lists
HTML Text Displayed in Browser
<!DOCTYPE html>
<html> Ordered List with Lowercase Roman
<body> Numbers
<h2>Ordered List with i. Coffee
Lowercase Roman ii. Tea
Numbers</h2> iii. Milk
<ol type="i">
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
HTML Lists
Nested HTML Lists
• List can be nested (lists inside lists):
</body>
HTML Tables
93
HTML Tables
HTML Table
• An HTML table is defined with the <table> tag.
• Each table row is defined with the <tr> tag. A table header is defined
with the <th> tag. By default, table headings are bold and centered. A
table data/cell is defined with the <td> tag.
HTML Tables
<!DOCTYPE html> <tr>
<html> <td>Eve</td>
<body> <td>Jackson</td>
<td>94</td>
<table> </tr>
<tr> <tr>
<th>Firstname</th> <td>John</td>
<th>Lastname</th> <td>Doe</td>
<th>Age</th> <td>80</td> Note that the <td>
</tr> </tr> elements are the data
<tr> </table> containers of the table.
<td>Jill</td> They can contain all sorts
<td>Smith</td> </body> of HTML elements; text,
<td>50</td> </html> images, lists, other
</tr>
tables, etc.
HTML Tables
HTML Table: Adding a Border
<!DOCTYPE html> <tr>
<html> <td>Eve</td>
<body> <td>Jackson</td>
<td>94</td>
<table border="1"> </tr>
<tr> <tr>
<th>Firstname</th> <td>John</td>
<th>Lastname</th> <td>Doe</td>
<th>Age</th> <td>80</td>
</tr> </tr>
<tr> </table>
<td>Jill</td>
<td>Smith</td> </body>
<td>50</td> </html>
</tr>
HTML Tables
<!DOCTYPE html> <tr>
<html> <td>Eve</td>
<body> <td>Jackson</td>
<td>94</td>
<table border="1" </tr>
style="width:100%"> <tr>
<tr> <td>John</td>
<th>Firstname</th> <td>Doe</td>
<th>Lastname</th> <td>80</td>
<th>Age</th> </tr>
</tr> </table>
<tr>
<td>Jill</td> </body>
<td>Smith</td> </html>
<td>50</td>
</tr>
Thank You