Professional Documents
Culture Documents
1. Introduction .................................................................................................................................... 1
2. HTML Editors ................................................................................................................................... 2
3. HTML Elements................................................................................................................................ 3
4. HTML Attributes .............................................................................................................................. 5
5. HTML Headings................................................................................................................................ 7
6. HTML Paragraphs ............................................................................................................................ 9
7. HTML Styles ................................................................................................................................... 10
8. HTML Text Formatting Elements .................................................................................................... 12
9. HTML Quotation and Citation Elements ......................................................................................... 13
10. HTML Computer Code Elements .................................................................................................... 14
11. HTML Comments ........................................................................................................................... 15
12. HTML Links .................................................................................................................................... 16
13. HTML Images ................................................................................................................................. 18
14. HTML Tables .................................................................................................................................. 21
15. HTML Lists ..................................................................................................................................... 26
16. HTML Block Elements .................................................................................................................... 29
17. HTML Layouts ................................................................................................................................ 30
18. HTML Responsive Web Design ....................................................................................................... 34
19. HTML Forms and Input .................................................................................................................. 35
20. HTML Iframes ................................................................................................................................ 38
21. HTML Scripts.................................................................................................................................. 39
22. HTML Head .................................................................................................................................... 39
23. HTML Entities ................................................................................................................................ 41
24. HTML Symbols ............................................................................................................................... 43
25. HTML Encoding (Character Sets) .................................................................................................... 44
26. HTML Uniform Resource Locators .................................................................................................. 45
27. HTML and XHTML .......................................................................................................................... 46
28. Complete HTML Tags ..................................................................................................................... 49
1. Introduction
What is HTML?
HTML is a markup language for describing web documents (web pages).
HTML stands for Hyper Text Markup Language
A markup language is a set of markup tags
HTML documents are described by HTML tags
Each HTML tag describes different document content
HTML Example: Small HTML document
<! DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Example Explained:
The DOCTYPE declaration defines the document type
The text between <html> and </html> describes the web document
The text between <body> and </body> describes the visible page content
The text between <h1> and </h1> describes a heading
The text between <p> and </p> describes paragraph
HTML Tags
HTML tags are keywords (tag names) surrounded by angle brackets:
Syntax: <tagname>content</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 slash before the tag name
The start tag is often called the opening tag. The end tag is often called the closing tag
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:
1
HTML Introduction by: Selama G. (Draft Copy)
HTML Page Structure
Below is a visualization of an HTML page structure:
HTML Versions
Since the early days of the web, there have been many versions of HTML:
Version Year
HTML 1991
HTML+ 1993
HTML 2.0 1995
HTML 3.2 1997
HTML 4.01 1999
XHTML 2000
HTML5 2012
2. HTML Editors
2
HTML Introduction by: Selama G. (Draft Copy)
Click Start (bottom left on your screen). Click All Programs. Click Accessories. Click
Notepad.
To open Notepad in Windows 8 or later:
Open the Start Screen (the window symbol at the bottom left on your screen). Type
Notepad.
3. HTML Elements
HTML Elements
3
HTML Introduction by: Selama G. (Draft Copy)
HTML elements are written with a start tag, with an end tag, with the content in
between:
<tagname>content</tagname>
The HTML element is everything from the start tag to the end tag:
<p>My first paragraph.</p>
Start tag Element content End tag
<h1> My First Heading </h1>
<p> My first paragraph. </p>
<br>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
The <h1> element defines a heading.
It has a start tag <h1> and an end tag </h1>.
The element content is: My First Heading.
<h1>My First Heading</h1>
4
HTML Introduction by: Selama G. (Draft Copy)
The <p> element defines a paragraph.
It has a start tag <p> and an end tag </p>.
The element content is: My first paragraph.
<p>My first paragraph.</p>
4. HTML Attributes
Attributes provide additional information about HTML elements.
HTML Attributes
HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes come in name/value pairs like: name="value"
5
HTML Introduction by: Selama G. (Draft Copy)
<!DOCTYPE html>
<html lang="en-US">
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
The first two letters specify the language (en). If there is a dialect, use two more letters
(US).
When you move the mouse over the element, the title will be displayed as a tooltip.
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:
Example
<img src="w3schools.jpg" width="104" height="142">
The image size is specified in pixels: width="104" means 104 screen pixels wide.
You will learn more about images and the <img> tag later in this chapter.
6
HTML Introduction by: Selama G. (Draft Copy)
We Suggest: Always Use Lowercase Attributes
The HTML5 standard does not require lower case attribute names.
The title attribute can be written with upper or lower case like Title and/or TITLE.
W3C recommends lowercase in HTML4, and demands lowercase for stricter document
types like XHTML.
Lower case is the most common. Lower case is easier to type.
At W3Schools we always use lower case attribute names.
Using quotes are the most common. Omitting quotes can produce errors.
At W3Schools we always use quotes around attribute values.
5. HTML Headings
HTML Headings
Headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading.
Example
<h1>This is a heading</h1>
<h2>This is a heading</h2>
<h3>This is a heading</h3>
Note: Browsers automatically add some empty space (a margin) before and after each heading.
7
HTML Introduction by: Selama G. (Draft Copy)
Headings Are Important
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.
h1 headings should be main headings, followed by h2 headings, then the less important
h3, and so on.
8
HTML Introduction by: Selama G. (Draft Copy)
Have you ever seen a Web page and wondered "Hey! How did they do that?"
To find out, right-click in the page and select "View Page Source" (in Chrome) or "View
Source" (in IE), or similar in another browser. This will open a window containing the
HTML code of the page.
6. HTML Paragraphs
HTML Paragraphs
The HTML <p> element defines a paragraph.
Example
<p>This is a paragraph</p>
<p>This is another paragraph</p>
HTML Display
You cannot be sure how HTML will be displayed.
Large or small screens, and resized windows will create different results.
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 spaces, and any number of new lines, count as only one space.
Example
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
<p>
This paragraph
contains a lot of spaces
in the source code,
but the browser
ignores it.
</p>
9
HTML Introduction by: Selama G. (Draft Copy)
Stricter versions of HTML, like XHTML, do not allow you to skip
the end tag.
7. HTML Styles
I am Red
I am Blue
HTML Styling
Every HTML element has a default style (background color is white, text color is black ...)
Changing the default style of an HTML element, can be done with the style attribute.
Example
<body style="background-color:lightgrey">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
10
HTML Introduction by: Selama G. (Draft Copy)
The bgcolor attribute, supported in older versions of HTML, is not valid in HTML5.
The <font> tag, supported in older versions of HTML, is not valid in HTML5.
11
HTML Introduction by: Selama G. (Draft Copy)
<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center">Centered Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
The <center> tag, supported in older versions of HTML, is not valid in HTML5.
12
HTML Introduction by: Selama G. (Draft Copy)
The HTML <em> element defines emphasized text, with added semantic importance.
Example
<p>This text is normal.</p>
<p><em>This text is emphasized</em>.</p>
Browsers display <strong> as <b>, and <em> as <i>.
However, there is a difference in the meaning of these tags: <b> and <i> defines bold and
italic text,
but <strong> and <em> means that the text is "important".
Example
<h2>HTML <mark>Marked</mark> Formatting</h2>
13
HTML Introduction by: Selama G. (Draft Copy)
HTML Long Quotations
The HTML <blockquote> element defines a quoted section.
Browsers usually indent <blockquote> elements.
Example
<p>Here is a quote from WWF's website:</p>
<blockquote cite="http://www.worldwildlife.org/who/index.html">
For 50 years, WWF has been protecting the future of nature.
The world's leading conservation organization,
WWF works in 100 countries and is supported by
1.2 million members in the United States and
close to 5 million globally.
</blockquote>
14
HTML Introduction by: Selama G. (Draft Copy)
Linux 2.6.10-grsec+gg3+e+fhs6b+nfs+gr0501+++p3+c4a+gr2b-reslog-v6.189
</samp>
Comments are not displayed by the browser, but they can help document your HTML.
15
HTML Introduction by: Selama G. (Draft Copy)
With comments you can place notifications and reminders in your HTML:
Example
<!-- This is a comment -->
<p>This is a paragraph.</p>
<!-- Remember to add more information here -->
Comments are also great for debugging HTML, because you can comment out HTML
lines of code, one at a time, to search for errors:
Example
<!-- Do not display this at the moment
<img border="0" src="pic_mountain.jpg" alt="Mountain">
-->
Conditional Comments
You might stumble upon conditional comments in HTML:
<!--[if IE 8]>
.... some HTML here ....
<![endif]-->
Conditional comments defines HTML tags to be executed by IE only.
Links are found in nearly all web pages. Links allow users to click their way from page to
page.
16
HTML Introduction by: Selama G. (Draft Copy)
Local Links
The example above 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....).
Example:
<a href="html_images.asp">HTML Images</a>
17
HTML Introduction by: Selama G. (Draft Copy)
style="width:42px;height:42px;border:0">
</a>
border:0 is added to prevent IE9 (and earlier) from displaying a border around the image.
Chapter Summary
Use the HTML <a> element to define a link
Use the HTML href attribute to define the link address
Use the HTML target attribute to define where to open the linked document
Use the HTML <img> element (inside <a>) to use an image as a link
Use the HTML id attribute (id=value) to define bookmarks in a page
Use the HTML href attribute (href="#value") to address the bookmark
<!DOCTYPE html>
<html>
<body>
18
HTML Introduction by: Selama G. (Draft Copy)
<h2>Spectacular Mountains</h2>
<img src="pic_mountain.jpg" alt="Mountain View"
style="width:304px;height:228px">
</body>
Always specify image size. If the size is unknown, the page will flicker while the image loads.
You can use the style attribute to specify the width and height of an image.
The values are specified in pixels (use px after the value):
Example
<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px">
Alternatively, you can use width and height attributes.
The values are specified in pixels (without px after the value):
Example
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">
19
HTML Introduction by: Selama G. (Draft Copy)
We suggest you use the style attribute. It prevents styles sheets from changing the default
size of images:
Example
<!DOCTYPE html>
<html>
<head>
<style>
img { width:100%; }
</style>
</head>
<body>
<img src="html5.gif" alt="HTML5 Icon" style="width:128px;height:128px">
<img src="html5.gif" alt="HTML5 Icon" width="128" height="128">
</body>
</html>
At W3schools we prefer to use the style attribute.
Animated Images
The GIF standard allows animated images:
Example
<img src="programming.gif" alt="Computer Man" style="width:48px;height:48px">
Note that the syntax of inserting animated images is no different from non-animated
images.
20
HTML Introduction by: Selama G. (Draft Copy)
It is common to use images as links:
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;border:0">
</a>
We have added border:0 to prevent IE9 (and earlier) from displaying a border around the
image.
Image Maps
For an image, you can create an image map, with clickable areas:
Example
<img src="planets.gif" alt="Planets" usemap="#planetmap"
style="width:145px;height:126px">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
Image Floating
You can let an image float to the left or right of a paragraph:
Example
<p>
<img src="smiley.gif" alt="Smiley face" style="float:left;width:42px;height:42px">
A paragraph with an image. The image floats to the left of the text.
</p>
Summary
Use the HTML <img> element to define images
Use the HTML src attribute to define the image file name
Use the HTML alt attribute to define an alternative text
Use the HTML width and height attributes to define the image size
Use the CSS width and height properties to define the image size (alternatively)
Use the CSS float property to define image floating
Use the CSS usemap attribute to point to an image map
Use the HTML <map> element to define an image map
Use the HTML <area> element to define image map areas
Loading images takes time. Large images can slow down your page. Use images carefully.
21
HTML Introduction by: Selama G. (Draft Copy)
1 Helen Bezabih 94
2 Yohannes Girma 80
3 Alem G/mariam 67
4 Tigist Worku 50
The border attribute is on its way out of the HTML standard! It is better to use CSS.
22
HTML Introduction by: Selama G. (Draft Copy)
table, th, td
{
border: 1px solid black;
}
Remember to define borders for both the table and the table cells.
23
HTML Introduction by: Selama G. (Draft Copy)
{
text-align: left;
}
24
HTML Introduction by: Selama G. (Draft Copy)
To add a caption to a table, use the <caption> tag:
Example:
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$50</td>
</tr>
</table>
The <caption> tag must be inserted immediately after the <table> tag.
Most of the examples above use a style attribute (width="100%") to define the width of
each table.
This makes it easy to define different widths for different tables.
The styles in the <head> section, however, define a style for all tables in a page.
To define a special style for a special table, add an id attribute to the table:
Example
<table id="t01">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Points</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Now you can define a different style for this table:
table#t01
{
width: 100%;
background-color: #f1f1c1;
}
And add more styles:
25
HTML Introduction by: Selama G. (Draft Copy)
table#t01 tr:nth-child(even)
{
background-color: #eee;
}
table#t01 tr:nth-child(odd)
{
background-color: #fff;
}
table#t01 th
{
color: white;
background-color: black;
}
15. HTML Lists
HTML can have Unordered Lists, Ordered Lists, or Description Lists:
Unordered HTML List Ordered HTML List HTML Description List
The first item 1. The first item The first item
The second item 2. The second item Description of item
The third item 3. The third item The second item
The fourth item 4. The fourth item Description of item
26
HTML Introduction by: Selama G. (Draft Copy)
<li>Milk</li>
</ul>
Square:
<ul style="list-style-type:square">
<li>Coffee</li>
<li>Tea
<li>Milk</li>
</ul>
None:
<ul style="list-style-type:none">
<li>Coffee</li>
<li>Tea
<li>Milk</li>
</ul>
Using a type attribute <ul type="disc">, instead of <ul style="list-style-type:disc">, also
works.
But in HTML5, the type attribute is not valid in unordered lists, only in ordered list.
27
HTML Introduction by: Selama G. (Draft Copy)
Roman Lower Case:
<ol type="i">
Roman Upper Case: <li>Coffee</li>
<ol type="I"> <li>Tea
<li>Coffee</li> <li>Milk</li>
<li>Tea </ol>
<li>Milk</li>
</ol>
Horizontal Lists
HTML lists can be styled in many different ways with CSS.
One popular way, is to style a list to display horizontally:
Horizontal List:
<! DOCTYPE html>
<html>
<head>
28
HTML Introduction by: Selama G. (Draft Copy)
<style>
ul#menu li
{
display:inline;
}
</style>
</head>
<body>
<h2>Horizontal List</h2>
<ul id="menu">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
</body>
</html>
With a little extra style, you can make it look like a menu:
o Tables
o Lists
o Blocks
o Classes
New Style:
ul#menu
{
padding: 0;
}
ul#menu li
{
display: inline;
}
ul#menu li a
{
background-color: black;
color: white;
padding: 10px 20px;
text-decoration: none;
border-radius: 4px 4px 0 0;
}
ul#menu li a:hover
{
background-color: orange;
}
29
HTML Introduction by: Selama G. (Draft Copy)
Examples: <h1>, <p>, <ul>, <table>
Inline elements are normally displayed without line breaks.
Examples: <b>, <td>, <a>, <img>
The HTML <div> Element
The HTML <div> element is a block level element that can be used as a container for
other HTML elements.
The <div> element has no special meaning. It has no required attributes, but style and
class are common.
Because it is a block level element, the browser will display line breaks before and after
it.
When used together with CSS, the <div> element can be used to style blocks of content.
The HTML <span> Element
The HTML <span> element is an inline element that can be used as a container for text.
The <span> element has no special meaning. It has no required attributes, but style and
class are common.
Unlike <div>, which is formatted with line breaks, the <span> element does not have any
automatic formatting.
When used together with CSS, the <span> element can be used to style parts of the text:
Example
<h1>My <span style="color:red">Important</span>Heading</h1>
30
HTML Introduction by: Selama G. (Draft Copy)
</div>
<div id="footer">
Copyright © W3Schools.com
</div>
</body>
The CSS:
<style>
#header
{
background-color:black;
color:white;
text-align:center;
padding:5px;
}
#nav
{
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}
#section
{
width:350px;
float:left;
padding:10px;
}
#footer
{
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
</style>
31
HTML Introduction by: Selama G. (Draft Copy)
header Defines a header for a document or a section
nav Defines a container for navigation links
section Defines a section in a document
article Defines an independent self-contained article
aside Defines content aside from the content (like a
sidebar)
footer Defines a footer for a document or a section
details Defines additional details
summary Defines a heading for the details element
This example uses <header>, <nav>, <section>, and <footer> to create a multiple column
layout:
Example:
<body>
<header>
<h1>City Gallery</h1>
</header>
<nav>
London<br>
Paris<br>
Tokyo<br>
</nav>
<section>
<h1>London</h1>
<p>
London is the capital city of England. It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.
</p>
<p>
Standing on the River Thames, London has been a major settlement for two millennia,
its history going back to its founding by the Romans, who named it Londinium.
</p>
</section>
<footer>
Copyright © W3Schools.com
</footer>
</body>
The CSS:
<style>
header {
background-color:black;
color:white;
text-align:center;
padding:5px;
}
32
HTML Introduction by: Selama G. (Draft Copy)
nav {
line-height:30px;
background-color:#eeeeee;
height:300px;
width:100px;
float:left;
padding:5px;
}
section {
width:350px;
float:left;
padding:10px;
}
footer {
background-color:black;
color:white;
clear:both;
text-align:center;
padding:5px;
}
33
HTML Introduction by: Selama G. (Draft Copy)
}
</style>
Using Bootstrap
34
HTML Introduction by: Selama G. (Draft Copy)
Another way to create a responsive design, is to use an already existing CSS framework.
Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive
webs.
Bootstrap helps you to develop sites that look nice at any size; screen, laptop, tablet, or
phone:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
</head>
<body>
<div class="container">
<div class="jumbotron">
<h1>W3Schools Demo</h1>
<p>Resize this responsive page!</p>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-4">
<h2>London</h2>
<p>London is the capital city of England.</p>
<p>It is the most populous city in the United Kingdom,
with a metropolitan area of over 13 million inhabitants.</p>
</div>
<div class="col-md-4">
<h2>Paris</h2>
<p>Paris is the capital and most populous city of France.</p>
</div>
<div class="col-md-4">
<h2>Tokyo</h2>
<p>Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
and the most populous metropolitan area in the world.</p>
</div>
</div>
</div>
</body>
</html>
19. HTML Forms and Input
35
HTML Introduction by: Selama G. (Draft Copy)
HTML Forms
HTML forms are used to pass data to a server.
An HTML form can contain input elements like text fields, checkboxes, radio-buttons,
submit buttons and more. A form can also contain select lists, textarea, fieldset, legend,
and label elements.
The <form> tag is used to create an HTML form:
<form>
.input elements
.</form>
Text Fields
<input type="text"> defines a one-line input field that a user can enter text into:
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
How the HTML code above looks in a browser:
First name:
Last name:
Note: The form itself is not visible. Also note that the default width of a text field is 20
characters.
Password Field
<input type="password"> defines a password field:
<form>
Password: <input type="password" name="pwd">
</form>
How the HTML code above looks in a browser:
*********
Password:
Note: The characters in a password field are masked (shown as asterisks or circles).
Radio Buttons
<input type="radio"> defines a radio button. Radio buttons let a user select ONLY ONE
of a limited number of choices:
<form>
<input type="radio" name="sex" value="male">Male<br>
36
HTML Introduction by: Selama G. (Draft Copy)
<input type="radio" name="sex" value="female">Female
</form>
How the HTML code above looks in a browser:
Male
Female
Checkboxes
<input type="checkbox"> defines a checkbox. Checkboxes let a user select ZERO or
MORE options of a limited number of choices.
<form>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car
</form>
How the HTML code above looks in a browser:
I have a bike
I have a car
Submit Button
<input type="submit"> defines a submit button.
A submit button is used to send form data to a server. The data is sent to the page
specified in the form's action attribute. The file defined in the action attribute usually
does something with the received input:
<form name="input" action="demo_form_action.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>
How the HTML code above looks in a browser:
Username:
If you type some characters in the text field above, and click the "Submit" button, the
browser will send your input to a page called "demo_form_action.asp". The page will
show you the received input.
37
HTML Introduction by: Selama G. (Draft Copy)
<datalist> Specifies a list of pre-defined options for input controls
<keygen> Defines a key-pair generator field (for forms)
<output> Defines the result of a calculation
Iframe Syntax
The syntax for adding an iframe is:
<iframe src="URL"></iframe>
The src attribute specifies the URL (web address) of the iframe page.
38
HTML Introduction by: Selama G. (Draft Copy)
Tag Description
<iframe> Defines an inline frame
39
HTML Introduction by: Selama G. (Draft Copy)
The HTML <title> Element
The <title> tag defines the title of the document.
The <title> element is required in all HTML/XHTML documents.
The <title> element:
defines a title in the browser toolbar
provides a title for the page when it is added to favorites
displays a title for the page in search engine results
40
HTML Introduction by: Selama G. (Draft Copy)
}
</style>
</head>
41
HTML Introduction by: Selama G. (Draft Copy)
Reserved characters in HTML must be replaced with character entities.
Characters, not present on your keyboard, can also be replaced by entities.
HTML Entities
Some characters are reserved in HTML.
If you use the less than (<) or greater than (>) signs in your text, the browser might mix
them with tags.
Character entities are used to display reserved characters in HTML.
A character entity looks like this:
&entity_name;
OR
&#entity_number;
To display a less than sign we must write: < or <
The advantage of using an entity name, instead of a number, is that the name is easier to remember.
The disadvantage is that browsers may not support all entity names, but the support for numbers is
good.
42
HTML Introduction by: Selama G. (Draft Copy)
̀ a à à
́ a á á
̂ a â â
̃ a ã ã
̀ O Ò Ò
́ O Ó Ó
̂ O Ô Ô
̃ O Õ Õ
43
HTML Introduction by: Selama G. (Draft Copy)
Γ Γ Γ GREEK CAPITAL LETTER GAMMA
Δ Δ Δ GREEK CAPITAL LETTER DELTA
Ε Ε Ε GREEK CAPITAL LETTER EPSILON
Ζ Ζ Ζ GREEK CAPITAL LETTER ZETA
To display an HTML page correctly, a web browser must know the character set
(character encoding) to use.
44
HTML Introduction by: Selama G. (Draft Copy)
If a browser detects ISO-8859-1 in a web page, it defaults to ANSI, because ANSI is
identical to ISO-8859-1 except that ANSI has 32 extra characters.
45
HTML Introduction by: Selama G. (Draft Copy)
path - defines a path at the server (If omitted: the root directory of the site)
filename - defines the name of a document or resource
URL Encoding
URLs can only be sent over the Internet using the ASCII character-set.
Since URLs often contain characters outside the ASCII set, the URL has to be converted
into ASCII.
URL encoding converts characters into a format that can be transmitted over the Internet.
URL encoding replaces non ASCII characters with a "%" followed by two hexadecimal
digits.
URLs cannot contain spaces. URL encoding normally replaces a space with a + sign.
What Is XHTML?
XHTML stands for EXtensible HyperText Markup Language
XHTML is almost identical to HTML 4.01
XHTML is a stricter and cleaner version of HTML
XHTML is HTML defined as an XML application
XHTML is supported by all major browsers
Why XHTML?
Many pages on the internet contain "bad" HTML.
The following HTML code will work fine if you view it in a browser (even if it does
NOT follow the HTML rules):
46
HTML Introduction by: Selama G. (Draft Copy)
<html>
<head>
<title>This is bad HTML</title>
<body>
<h1>Bad HTML
<p>This is a paragraph
</body>
XML is a markup language where documents must be marked up correctly and must be
"well-formed".
Today's market consists of different browser technologies. Some browsers run on
computers, and some browsers run on mobile phones or other small devices. Smaller
devices often lack the resources or power to interpret a "bad" markup language.
Therefore - by combining the strengths of HTML and XML, XHTML was developed.
XHTML is HTML redesigned as XML.
Document Structure
XHTML DOCTYPE is mandatory
The xmlns attribute in <html> is mandatory
<html>, <head>, <title>, and <body> are mandatory
XHTML Elements
XHTML elements must be properly nested
XHTML elements must always be closed
XHTML elements must be in lowercase
XHTML documents must have one root element
XHTML Attributes
Attribute names must be in lower case
Attribute values must be quoted
Attribute minimization is forbidden
47
HTML Introduction by: Selama G. (Draft Copy)
In XHTML, all elements must be properly nested within each other, like this:
<b><i>This text is bold and italic</i></b>
48
HTML Introduction by: Selama G. (Draft Copy)
<input disabled>
<option selected>
This is correct:
<input checked="checked">
<input readonly="readonly">
<input disabled="disabled">
<option selected="selected">
http://w w w .w 3schools.com/html/demo_xhtml.asp
49
HTML Introduction by: Selama G. (Draft Copy)
<blockquote> Defines a section that is quoted from another source
<body> Defines the document's body
<br> Defines a single line break
<button> Defines a clickable button
<canvas>5 Used to draw graphics, on the fly, via scripting (usually JavaScript)
<caption> Defines a table caption
<center>R Not supported in HTML5. Use CSS instead.
Defines centered text
<cite> Defines the title of a work
<code> Defines a piece of computer code
<col> Specifies column properties for each column within a <colgroup>
element
<colgroup> Specifies a group of one or more columns in a table for formatting
<datalist>5 Specifies a list of pre-defined options for input controls
<dd> Defines a description/value of a term in a description list
<del> Defines text that has been deleted from a document
<details>5 Defines additional details that the user can view or hide
<dfn> Defines a definition term
<dialog>5 Defines a dialog box or window
<dir>R Not supported in HTML5. Use <ul> instead.
Defines a directory list
<div> Defines a section in a document
<dl> Defines a description list
<dt> Defines a term/name in a description list
<em> Defines emphasized text
<embed>5 Defines a container for an external (non-HTML) application
<fieldset> Groups related elements in a form
<figcaption>5 Defines a caption for a <figure> element
<figure>5 Specifies self-contained content
<font>R Not supported in HTML5. Use CSS instead.
Defines font, color, and size for text
<footer>5 Defines a footer for a document or section
<form> Defines an HTML form for user input
<frame>R Not supported in HTML5.
Defines a window (a frame) in a frameset
<frameset>R Not supported in HTML5.
Defines a set of frames
<h1> to <h6> Defines HTML headings
<head> Defines information about the document
<header>5 Defines a header for a document or section
<hgroup>5 Defines a group of headings
<hr> Defines a thematic change in the content
<html> Defines the root of an HTML document
<i> Defines a part of text in an alternate voice or mood
<iframe> Defines an inline frame
<img> Defines an image
<input> Defines an input control
<ins> Defines a text that has been inserted into a document
50
HTML Introduction by: Selama G. (Draft Copy)
<kbd> Defines keyboard input
<keygen>5 Defines a key-pair generator field (for forms)
<label> Defines a label for an <input> element
<legend> Defines a caption for a <fieldset> element
<li> Defines a list item
<link> Defines the relationship between a document and an external resource
(most used to link to style sheets)
<main>5 Specifies the main content of a document
<map> Defines a client-side image-map
<mark>5 Defines marked/highlighted text
<menu> Defines a list/menu of commands
<menuitem>5 Defines a command/menu item that the user can invoke from a popup
menu
<meta> Defines metadata about an HTML document
<meter>5 Defines a scalar measurement within a known range (a gauge)
<nav>5 Defines navigation links
<noframes>R Not supported in HTML5.
Defines an alternate content for users that do not support frames
<noscript> Defines an alternate content for users that do not support client-side
scripts
<object> Defines an embedded object
<ol> Defines an ordered list
<optgroup> Defines a group of related options in a drop-down list
<option> Defines an option in a drop-down list
<output>5 Defines the result of a calculation
<p> Defines a paragraph
<param> Defines a parameter for an object
<pre> Defines preformatted text
<progress>5 Represents the progress of a task
<q> Defines a short quotation
<rp>5 Defines what to show in browsers that do not support ruby annotations
<rt>5 Defines an explanation/pronunciation of characters (for East Asian
typography)
<ruby>5 Defines a ruby annotation (for East Asian typography)
<s> Defines text that is no longer correct
<samp> Defines sample output from a computer program
<script> Defines a client-side script
<section>5 Defines a section in a document
<select> Defines a drop-down list
<small> Defines smaller text
<source>5 Defines multiple media resources for media elements (<video> and
<audio>)
<span> Defines a section in a document
<strike>R Not supported in HTML5. Use <del> instead.
Defines strikethrough text
<strong> Defines important text
<style> Defines style information for a document
<sub> Defines subscripted text
51
HTML Introduction by: Selama G. (Draft Copy)
<summary>5 Defines a visible heading for a <details> element
<sup> Defines superscripted text
<table> Defines a table
<tbody> Groups the body content in a table
<td> Defines a cell in a table
<textarea> Defines a multiline input control (text area)
<tfoot> Groups the footer content in a table
<th> Defines a header cell in a table
<thead> Groups the header content in a table
<time>5 Defines a date/time
<title> Defines a title for the document
<tr> Defines a row in a table
<track>5 Defines text tracks for media elements (<video> and <audio>)
<tt>R Not supported in HTML5. Use CSS instead.
Defines teletype text
<u> Defines text that should be stylistically different from normal text
<ul> Defines an unordered list
<var> Defines a variable
<video>5 Defines a video or movie
<wbr>5 Defines a possible line-break
HTML Tags with Attributes
<a>
52
HTML Introduction by: Selama G. (Draft Copy)
shape default Not supported in HTML5.
rect Specifies the shape of a link
circle
poly
target _blank Specifies where to open the linked document
_parent
_self
_top
framename
type media_type Specifies the media type of the linked document
<canvas>
Attribute Value Description
height pixels Specifies the height of the canvas
width pixels Specifies the width of the canvas
<body>
Attribute Value Description
alink color Not supported in HTML5.
Specifies the color of an active link in a document
background URL Not supported in HTML5.
Specifies a background image for a document
bgcolor color Not supported in HTML5.
Specifies the background color of a document
link color Not supported in HTML5.
Specifies the color of unvisited links in a document
text color Not supported in HTML5.
Specifies the color of the text in a document
vlink color Not supported in HTML5.
Specifies the color of visited links in a document
<button>
= New in HTML5.
Attribute Value Description
autofocus autofocus Specifies that a button should
automatically get focus when the page
loads
disabled disabled Specifies that a button should be
disabled
form form_id Specifies one or more forms the button
belongs to
formaction URL Specifies where to send the form-data
when a form is submitted. Only for
type="submit"
formenctype application/x-www-form- Specifies how form-data should be
urlencoded encoded before sending it to a server.
multipart/form-data Only for type="submit"
text/plain
formmethod get Specifies how to send the form-data
post (which HTTP method to use). Only for
53
HTML Introduction by: Selama G. (Draft Copy)
type="submit"
formnovalidate formnovalidate Specifies that the form-data should not
be validated on submission. Only for
type="submit"
formtarget _blank Specifies where to display the response
_self after submitting the form. Only for
_parent type="submit"
_top
framename
name name Specifies a name for the button
type button Specifies the type of button
reset
submit
value text Specifies an initial value for the button
<div>
Attribute Value Description
align left Not supported in HTML5.
right Specifies the alignment of the content inside a <div> element
center
justify
<font>
Attribute Value Description
color rgb(x,x,x) Not supported in HTML5.
#xxxxxx Specifies the color of text
colorname
face font_family Not supported in HTML5.
Specifies the font of text
size number Not supported in HTML5.
Specifies the size of text
<form>
Attribute Value Description
accept file_type Not supported in HTML5.
Specifies a comma-separated list of file types that
the server accepts (that can be submitted through
the file upload)
accept-charset character_set Specifies the character encodings that are to be
used for the form submission
action URL Specifies where to send the form-data when a form
is submitted
autocomplete on Specifies whether a form should have
off autocomplete on or off
enctype application/x-www-form- Specifies how the form-data should be encoded
urlencoded when submitting it to the server (only for
multipart/form-data method="post")
text/plain
method get Specifies the HTTP method to use when sending
post form-data
54
HTML Introduction by: Selama G. (Draft Copy)
name text Specifies the name of a form
novalidate novalidate Specifies that the form should not be validated
when submitted
target _blank Specifies where to display the response that is
_self received after submitting the form
_parent
_top
<img>
Attribute Value Description
align top Not supported in HTML5.
bottom Specifies the alignment of an image according to
middle surrounding elements
left
right
alt text Specifies an alternate text for an image
border pixels Not supported in HTML5.
Specifies the width of the border around an image
crossorigin anonymous Allow images from third-party sites that allow cross-
use-credentials origin access to be used with canvas
height pixels Specifies the height of an image
hspace pixels Not supported in HTML5.
Specifies the whitespace on left and right side of an
image
ismap ismap Specifies an image as a server-side image-map
longdesc URL Not supported in HTML5.
Specifies the URL to a document that contains a long
description of an image
src URL Specifies the URL of an image
usemap #mapname Specifies an image as a client-side image-map
vspace pixels Not supported in HTML5.
Specifies the whitespace on top and bottom of an image
width pixels Specifies the width of an image
<input>
Attribute Value Description
accept file_extension Specifies the types of files that the server accepts
audio/* (only for type="file")
video/*
image/*
media_type
align left Not supported in HTML5.
right Specifies the alignment of an image input (only for
top type="image")
middle
bottom
alt text Specifies an alternate text for images (only for
type="image")
55
HTML Introduction by: Selama G. (Draft Copy)
autocomplete on Specifies whether an <input> element should have
off autocomplete enabled
autofocus autofocus Specifies that an <input> element should
automatically get focus when the page loads
checked checked Specifies that an <input> element should be pre-
selected when the page loads (for type="checkbox" or
type="radio")
disabled disabled Specifies that an <input> element should be disabled
form form_id Specifies one or more forms the <input> element
belongs to
formaction URL Specifies the URL of the file that will process the
input control when the form is submitted (for
type="submit" and type="image")
formenctype application/x-www- Specifies how the form-data should be encoded when
form-urlencoded submitting it to the server (for type="submit" and
multipart/form-data type="image")
text/plain
formmethod get Defines the HTTP method for sending data to the
post action URL (for type="submit" and type="image")
formnovalidate formnovalidate Defines that form elements should not be validated
when submitted
formtarget _blank Specifies where to display the response that is
_self received after submitting the form (for type="submit"
_parent and type="image")
_top
framename
height pixels Specifies the height of an <input> element (only for
type="image")
list datalist_id Refers to a <datalist> element that contains pre-
defined options for an <input> element
max number Specifies the maximum value for an <input> element
date
maxlength number Specifies the maximum number of characters allowed
in an <input> element
min number Specifies a minimum value for an <input> element
date
multiple multiple Specifies that a user can enter more than one value in
an <input> element
name text Specifies the name of an <input> element
pattern regexp Specifies a regular expression that an <input>
element's value is checked against
placeholder text Specifies a short hint that describes the expected
value of an <input> element
readonly readonly Specifies that an input field is read-only
required required Specifies that an input field must be filled out before
submitting the form
size number Specifies the width, in characters, of an <input>
element
src URL Specifies the URL of the image to use as a submit
56
HTML Introduction by: Selama G. (Draft Copy)
button (only for type="image")
step number Specifies the legal number intervals for an input field
type button Specifies the type <input> element to display
checkbox
color
date
datetime
datetime-local
email
file
hidden
image
month
number
password
radio
range
reset
search
submit
tel
text
time
url
week
value text Specifies the value of an <input> element
<ol>
Attribute Value Description
compact compact Not supported in HTML5.
Specifies that the list should render smaller than normal
reversed reversed Specifies that the list order should be descending (9,8,7...)
start number Specifies the start value of an ordered list
type 1 Specifies the kind of marker to use in the list
A
a
I
i
57
HTML Introduction by: Selama G. (Draft Copy)