L1 - HTML
L1 - HTML
• 1.1 Introduction
• 1.2 HTML tags
• 1.3 HTML attributes
• 1.4 Common tags
• 1.5 Forms
• 1.6 New features in HTML 5
• 1.7 XHTML v.s. HTML
• 1.8 HTML DOM
• 1.9 Practices
1
1.1 Introduction
2
What is HTML?
4
A Simple HTML Document
HTML Tags
The <!DOCTYPE html> declaration defines
<!DOCTYPE html> this document to be HTML5
<html> The <html> element is the root element
<head> of an HTML page
<title>Page Title</title> The <head> element contains meta
</head> information about the document
<body> The <title> element specifies a title for
<h1>My First Heading</h1> the document
<p>My first paragraph.</p> The <body> element contains the visible
<p>This is another page content
paragraph.</p> The <h1> element defines a large heading
</body>
</html>
The <p> element defines a paragraph
5
HTML Page Structure
Below is a visualization of an HTML page structure:
Note: Only the content inside the <body> section (the white area
above) is displayed in a browser.
6
Web Browsers
7
HTML Editors
Write HTML Using Notepad or TextEdit
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).
I recommend the following IDEs.
8
HTML History
Year Version
9
1.2 HTML Tag
10
HTML Tags
• HTML is comprised of “elements” and “tags”
• HTML tags are keywords surrounded by angle
brackets like <html>.
• HTML tags normally come in pairs like <p> and
</p> .
XHTML must be come in pairs.
• Tags are nested one inside another: the first tag in
a pair is the start tag, the second tag is the end tag.
Note: The start and end tags are also called the
opening and closing tags.
11
First HTML file
12
HTML Tags
• Do not forget the end tag.
• Some HTML elements will display correctly, even if you
forget the end tag:
<html>
<body>
The example above works in all
<p>This is a paragraph
<p>This is a paragraph
browsers, because the closing
tag is considered optional.
</body>
</html>
13
HTML Tags
• HTML elements with no content are called empty elements.
• <br> is an empty element without a closing tag (the <br> tag
defines a line break):
<p>This is a <br> paragraph with a line
break.</p>
15
1.3 HTML Attribute
16
HTML - Attributes
• Attributes provide additional information about HTML elements.
• All HTML elements can have attributes
• Attributes are always specified in the start tag
• Attributes usually come in name/value pairs like: name="value"
Attribute name
<a href="https://www.w3schools.com">This is a
link</a>
Attribute
value
HTML links are defined with the <a> tag. 17
HTML - Attributes
<img src="img_girl.jpg">
• HTML images also have width and height attributes, which
specifies the width and height of the image:
18
HTML - Attributes
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_attributes_alt_error
19
HTML - Attributes
<tagname style="property:value
;">
• This example sets the background color for a page to powderblue:
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_styles_background-color
20
HTML - Attributes
<fieldset name="personalia">
Name: <input type="text"><br>
Email: <input type="text"><br>
</fieldset>
21
HTML - Attributes
• Summary
All HTML elements can have attributes
The title attribute provides additional "tool-tip"
information
The href attribute provides address information for links
The width and height attributes provide size information
for images
The alt attribute provides text for screen readers
At W3Schools we always use lowercase attribute names
At W3Schools we always quote attribute values
23
HTML - Attributes
Below is an alphabetical list of some attributes often used in
HTML, which you will learn more about in this lecture:
Attribute Description
alt Specifies an alternative text for an image, when the image cannot
be displayed
disabled Specifies that an input element should be disabled
href Specifies the URL (web address) for a link
id Specifies a unique id for an element
src Specifies the URL (web address) for an image
style Specifies an inline CSS style for an element
title Specifies extra information about an element (displayed as a tool
tip)
https://www.w3schools.com/tags/ref_attributes.asp
24
1.4 Common Tags
25
HTML & Head
HTML Tag:
<html> … </html> (Required!)
Basic tag to identify portion of file that contains HTML
<html> is an opening tag
</html> is a closing tag (note the direction of the slash!)
text between the opening and closing tag is called the “content”
Head Tag:
<head> … </head> (Required!)
placed at the top of document immediately after the <html> tag
tags information about the document, e.g. author, style, etc.
contains the required document <title>...</title> tag
26
Meta
Meta Tag:
<meta>
It is used to specify keywords that describe a
document’s contents as well as a short description.
Two necessary attributes – "name" & "content"
<meta name="keywords" content="baseball, soccer,
tennis"/>
<meta name="description" content="Sports
information page"/>
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_meta
27
Title & Body
Title Tag:
<title> … </title> (Required!)
included as an element inside the <head>…</head> section
element of this tag is the title displayed in title bar of the browser
may also be used as title of page when page is bookmarked
should be meaningful and uniquely identify the page
Body Tag:
<body> … </body> (Required!)
included as the second element inside the <html>…</html> tags.
follows the <head>…</head> portion of the document
contains the information to be displayed in the browser window
any attributes set on this tag will apply to the entire page
28
Paragraphs & Document Type
Paragraph tag:
<p> … </p>
included as an element inside the <body>…</body>
section
Surrounds a paragraph of text
29
Preformatted Text
Preformatted text tag:
<pre></pre>
the HTML <pre> element defines preformatted text.
The text inside a <pre> element is displayed in a fixed-width
font (usually Courier), and it preserves both spaces and line
breaks
<pre>
My Bonnie lies over the ocean.
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_pre
30
Headings
Heading Tag:
<h1> … </h1> through <h6> ... </h6>
used to identify text as a Level 1 (major) to Level 6 (minor) heading
Code: Output:
<h1>This is first heading</h1> This is first
heading
<h2>This is first heading</h2> This is first
heading
<h3>This is first heading</h3> This is first
heading
<h4>This is first heading</h4> This is first heading
<h5>This is first heading</h5> This is first heading 31
<h6>This is first heading</h6> This is first heading
Headings
Heading Tag:
Search engines use the headings to index the structure and
content of your web pages.
The HTML <head> element is a container for metadata. HTML
metadata is data about the HTML document. Metadata is not
displayed.
Horizontal Rules:
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:
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_headings_hr
32
Links
The Anchor Tag OR Hyper Linking Tag
<a> … </a> (Local link)
one major attribute – the location of the hyperlink:
href=”string”
element is clickable/selectable as a document
hyperlink
browser attempts to load the page specified by
the href= attribute
the href= string can be a relative URL on the
same server:
without the leading http://host/ it is in the same directory
structure:
e.g. <a href=“page2.html”>Click here to continue</a>
e.g. <a href=”images/box.jpg”>See the box here.</a>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_links 33
Links
Anchor Tag:
<a>…</a> (Hyper link)
The href= string can be an absolute URL on any
server:
string can be any HTTP URL (web address) you like:
e.g. <a href=“http://www.gnu.org/philosophy/”>Free Software</a>
e.g <a href=“http://google.com” target=“_blank”>Google</a>
The href= string can be an email address:
string can be an email address preceded by “mailto:”
e.g. <a href=”mailto:[email protected]”>Ian! D. Allen email</a>
Attempts to open an email client (specified in the web browser's
options) and places the specified email address in the To: field of a
new email message.
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_links
34
Links
Anchor Tag - Bookmarks
<a>…</a> (Inside link, Bookmark)
• To name/mark a section of a document so that it
can be referred to by name later
• Identified by a name
• <a name=“itemname”>…</a>
• Referred to by a leading # within the same document
• <a href=“#itemname”>…</a>
• Or referred to from a different document
• <a href=“URL#itemname”>…</a>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_links_bookmark
35
Links
HTML Links – The target Attribute:
The target attribute specifies where to open the linked
document. The target attribute can have one of the
following values:
_blank - Opens the linked document in a new window or tab
_self - Opens the linked document in the same window/tab as it
was clicked (this is default)
_parent - Opens the linked document in the parent frame
_top - Opens the linked document in the full body of the window
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_links_target
36
Images
Image Tag:
<img> (no closing tag needed)
used to display pictures (.jpeg, .png, .gif) in your web pages
you must specify the URL for the image source
the basic attributes of <img> are:
src=”string” - the absolute or relative location of the image file
alt=”string” - Alternate Text for people who don't see images
height=”string” - image height, percent or absolute pixels (optional)
width=”string” - image width, percent or absolute pixels (optional)
<img src="pic_trulli.jpg" alt="Italian Trulli">
<img src="https://www.w3schools.com/images/
w3schools_green.jpg" alt="W3Schools.com">
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_images_size 37
Images
Links – Image as link
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial”>
</a>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_links_image
38
Image Map
Image Maps
The <map> tag defines an image-map. An image-map is an image with
clickable areas.
The idea behind an image map is that you should be able to perform
different actions depending on where in the image you click.
To create an image map you need an image, and a map containing some
rules that describe the clickable areas.
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer
.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm
">
<area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.htm"
>
</map>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_images_map2
39
Image Map
Image Maps
• You must define the shape of the area, and you can choose
one of these values:
• rect - defines a rectangular region
• circle - defines a circular region
• poly - defines a polygonal region
• default - defines the entire region
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="computer
.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="phone.htm
">
<area shape="circle" coords="337,300,44" alt="Coffee" href="coffee.htm"
>
</map>
40
TIP: Coordinates
• You must define some coordinates to be able to place the clickable area
onto the image.
• The coordinates come in pairs, one for the x-axis and one for the y-axis.
• The coordinates 34, 44 is located 34 pixels from the left margin and 44
pixels from the top:
• The coordinates 270, 350 is located 270 pixels from the left margin and 350
pixels from the top:
41
Picture
Picture Element
HTML5 introduced the <picture> element to add more flexibility
when specifying image resources.
The <picture> element contains a number of <source> elements,
each referring to different image sources. This way the browser
can choose the image that best fits the current view and/or
device.
Each <source> element have attributes describing when their
image is the most suitable.
<picture>
<source media="(min-width:
650px)" srcset="img_food.jpg">
<source media="(min-width:
465px)" srcset="img_car.jpg">
<img src="img_girl.jpg">
</picture>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_images_picture1
42
Comments
Comments:
To comment a section of a document
<!-- comments -->
<comment> comments </comment>
May appear any place in a document
43
Text Formatting
Text Formatting
HTML uses elements like <b> and <i> for formatting
output, like bold or italic text.
Tag Description
<b> Defines bold text
<em> Defines emphasized text
<i> Defines italic text
<small> Defines smaller text
<strong> Defines important text
<sub> Defines subscripted text
<sup> Defines superscripted text
https://www.w3schools.com/html/tryit.asp
?filename=tryhtml_formatting_intro <ins> Defines inserted text
<del> Defines deleted text
<mark> Defines marked/highlighted text
44
Table
Table elements
<table>…</table>
<table>
<tr>
<th>Firstname</
th> • Each table row is defined with
<th>Lastname</ the <tr> tag.
th>
<th>Age</th> • A table header is defined with
</tr> the <th> tag.
<tr>
<td>Jill</td> • By default, table headings are bold
<td>Smith</td> and centered.
<td>50</td>
</tr>
• A table data/cell is defined with
<tr> the <td> tag.
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_intro
45
Table
Table elements
To add a caption to a table, use the <caption> tag
To make a cell span more than one column, use the colspan attribute:
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2">Telephone</
th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_colspan
46
Table
Table elements
To add a caption to a table, use the <caption> tag
To make a cell span more than one row, use the rowspan attribute:
<table style="width:100%">
<caption>Monthly savings</caption>
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan="2">Telephone:</th>
<td>55577854</td>
</tr>
<tr>
<td>55577855</td>
</tr>
</table>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_rowspan
47
Table
Table elements
Tag Description
<table> Defines a table
<th> Defines a header cell in a table
<tr> Defines a row in a table
<td> Defines a cell in a table
<caption> Defines a table caption
<colgroup> Specifies a group of one or more columns in a table for formatting
https://www.w3schools.com/tags/tag_thead.asp 48
Lists
Unordered List
<ul>…</ul>
An unordered list starts with the <ul> tag. Each list item
starts with the <li> tag.
The list items will be marked with bullets (small black
circles) by default:
<ul>
<li>Coffee</
li>
<li>Tea</li>
<li>Milk</li>
</ul>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_lists_unordered
49
Lists
Ordered List:
<ol>…</ol>
An ordered list starts with the <ol> tag. Each list item
starts with the <li> tag.
The list items will be marked with numbers by default:
Type Description
<ol> type="1" The list items will be numbered with numbers
<li>Coffee</ (default)
li> type="A" The list items will be numbered with
<li>Tea</li> uppercase letters
<li>Milk</li> type="a" The list items will be numbered with
</ol> lowercase letters
https://www.w3schools.com/html/tryit.asp?file type="I" The list items will be numbered with
name=tryhtml_lists_ordered_numbers
uppercase roman numbers
type="i" The list items will be numbered with
lowercase roman numbers
50
Grouping
Block-level element
<div>…</div>
A block-level element always starts on a new line and takes up the full width
available (stretches out to the left and right as far as it can).
The <div> element is often used as a container for other HTML elements.
The <div> element has no required attributes, but both style and class are
common.
When used together with CSS, the <div> element can be used to style blocks of
content:
<div style="background-
color:black;color:white;padding:20px;">
<h2>London</h2>
<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>
</div>
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_div_test
51
Grouping
Inline element
<span>…</span>
The <span> element is often used as a container for some text.
The <span> element has no required attributes, but
both style and class are common.
When used together with CSS, the <span> element can be used to
style parts of the text:
<h1>My <span style="color:red">Important</
span> Heading</h1>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_inline_span
Tag Description
<div> Defines a section in a document (block-level)
<span> Defines a section in a document (inline)
52
Iframe
Iframe element
<iframe src="URL"></iframe>
An iframe is used to display a web page within a web page.
Use the height and width attributes to specify the size of
the iframe.
<iframe src="demo_iframe.htm" height="200" width="300"></
iframe>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_height_width_css
An iframe can be used as the target frame for a link.
The target attribute of the link must refer to
the name attribute of the iframe:
<iframe src="demo_iframe.htm" name="iframe_a"></
iframe>
<p><a href="https://
www.w3schools.com" target="iframe_a">W3Schools.com</
a></p> https://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target 53
HTML – Entities
Reserved characters in HTML must be replaced with character
entities.
Characters that are not present on your keyboard can also be
replaced by entities.
Result Description Entity Name Entity Number
54
HTML – Symbols
Many mathematical, technical, and currency symbols, are not
present on a normal keyboard. To add such symbols to an
HTML page, you can use an HTML entity name.
If no entity name exists, you can use an entity number, a
decimal,
Char
or hexadecimal
Number Entity
reference.
Description
∀ ∀ ∀ FOR ALL
∂ ∂ ∂ PARTIAL DIFFERENTIAL
∃ ∃ ∃ THERE EXISTS
∅ ∅ ∅ EMPTY SETS
∇ ∇ ∇ NABLA
∈ ∈ ∈ ELEMENT OF
∉ ∉ ∉ NOT AN ELEMENT OF
∋ ∋ ∋ CONTAINS AS MEMBER
∏ ∏ ∏ N-ARY PRODUCT
∑ ∑ ∑ N-ARY SUMMATION
Emoji Value
🗻 🗻
🗼 🗼
🗽 🗽
🗾 🗾
🗿 🗿
😀 😀
😁 😁
😂 😂
😃 😃
😄 😄
😅 😅
Reference: https://www.w3schools.com/charsets/ref_emoji.asp
56
1.5 HTML Forms
57
What are forms?
• <form> is just a group of HTML tags
• Forms are used to create GUIs on Web pages
• Usually the purpose is to ask the user for information
• The information is then sent back to the server
• A form is an area that can contain form tags
• The syntax is: <form attributes> ...form tags... </form>
• Form elements include: buttons, checkboxes, text fields, radio
buttons, drop-down menus, and so on.
• Other kinds of tags can be mixed in with the form elements
• A form usually contains a Submit button to send the information in
he form elements to the server
• The form’s attributes tell JavaScript how to send the information to
the server (there are two different ways it could be sent)
• Forms can be used for other things, such as a GUI for simple
programs
58
The <form> tag
• The <form attributes> ... </form> tag encloses form elements (and probably
other elements as well)
• The attributes to form tell what to do with the user input
• action=“url” (required)
• Specifies where to send the data when the Submit button is clicked
• method=“get” (default)
• Form data is sent as a URL with ?form_data info appended to the
end
• Can be used only if data is all ASCII and not more than 100
characters
• method="post"
• Form data is sent in the body of the URL request
• Cannot be bookmarked by most browsers
• target="target"
• Tells where to open the page sent as a result of the request
• target= _blank means open in a new window
• target= _top means use the same window
59
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit
The <input> tag
• Most, but not all, form elements use the input tag, with a
type="..." argument to tell which kind of element it is
• type can be text, checkbox, radio, password,
hidden, submit, reset, button, file, or image
• Other common input tag arguments include:
• name: the name of the element
• id: a unique identifier for the element
• value: the “value” of the element; used in different
ways for different values of type
• readonly: the value cannot be changed
• disabled: the user can’t do anything with this element
• Other arguments are defined for the input tag but have
meaning only for certain values of type
60
The <input> tag
• https://www.w3schools.com/html/html_form_input_types.asp
61
1.6 HTML 5
62
New Functions in HTML5
63
New Semantic Elements in HTML 5
Tag Description
<article> Defines an article in a document
<aside> Defines content aside from the page content
The most
<bdi>
interesting new API's in HTML5
Isolates a part of text that might be formatted in a different direction from other text outside it
<details> Defines additional details that the user can view or hide
are:
<dialog>
<figcaption>
Defines a dialog box or window
Defines a caption for a <figure> element
<figure> Defines self-contained content
• HTMLDefines
<footer> Geolocation
a footer for a document or section
<header> Defines a header for a document or section
• HTMLDefines
<main> Drag and
the main content Drop
of a document
<mark> Defines marked/highlighted text
• HTMLDefines
<menuitem>
Local Storage
a command/menu item that the user can invoke from a popup menu
<meter> Defines a scalar measurement within a known range (a gauge)
•
<nav>
HTML
<progress>
Application Cache
Defines navigation links
Represents the progress of a task
<rp> Defines what to show in browsers that do not support ruby annotations
•
<rt> HTML Web
Defines Workers
an explanation/pronunciation of characters (for East Asian typography)
<ruby> Defines a ruby annotation (for East Asian typography)
• HTMLDefines
<section> SSE a section in a document
<summary> Defines a visible heading for a <details> element
<time> Defines a date/time
<wbr> Defines a possible line-break
64
https://www.w3schools.com/html/html5_semantic_elements.asp
New Graphics in HTML 5
Canvas
<canvas> … </canvas>
The HTML <canvas> element is used to draw graphics, on the
fly, 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.
https://www.w3schools.com/html/html5_canvas.asp
65
New graphics in HTML 5
SVG
<svg> … </svg> (Scalable Vector Graphics)
The HTML <svg> element is a container for SVG graphics.
SVG has several methods for drawing paths, boxes, circles, text,
and graphic images.
https://www.w3schools.com/html/html5_svg.asp
66
New Media Elements in HTML 5
Tag Description
<audio> Defines sound content
<embed> Defines a container for an external (non-HTML) application
<source> Defines multiple media resources for media elements (<video> and <audio>)
<track> Defines text tracks for media elements (<video> and <audio>)
<video> Defines video or movie
67
New Media Elements in HTML 5
Audio
<audio> … </audio>
The controls attribute adds audio controls, like play, pause, and
volume.
The <source> element allows you to specify alternative audio
files which the browser may choose from. The browser will use
the first recognized format.
The text between the <audio> and </audio> tags will only be
displayed in browsers that do not support the <audio> element.
<audio controls>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio
element.
</audio>
https://www.w3schools.com/html/html5_audio.asp
68
New Media Elements in HTML 5
Video
<video> … </video>
The controls attribute adds video controls, like play, pause, and
volume.
It is a good idea to always include width and height attributes. If
height and width are not set, the page might flicker while the video
loads.
The <source> element allows you to specify alternative video files
which the browser may choose from. The browser will use the first
recognized format.
The text between the <video> and </video> tags will only be
displayed in browsers that do not support the <video> element.
https://www.w3schools.com/html/html5_video.asp 69
New Media Elements in HTML 5
Format File Description
MPEG .mpg MPEG. Developed by the Moving Pictures Expert Group. The first popular video format on the
.mpeg web. Used to be supported by all browsers, but it is not supported in HTML5 (See MP4).
AVI .avi AVI (Audio Video Interleave). Developed by Microsoft. Commonly used in video cameras and
TV hardware. Plays well on Windows computers, but not in web browsers.
WMV .wmv WMV (Windows Media Video). Developed by Microsoft. Commonly used in video cameras
and TV hardware. Plays well on Windows computers, but not in web browsers.
QuickTime .mov QuickTime. Developed by Apple. Commonly used in video cameras and TV hardware. Plays
well on Apple computers, but not in web browsers. (See MP4)
RealVideo .rm RealVideo. Developed by Real Media to allow video streaming with low bandwidths. It is still
.ram used for online video and Internet TV, but does not play in web browsers.
Flash .swf Flash. Developed by Macromedia. Often requires an extra component (plug-in) to play in web
.flv browsers.
Ogg .ogg Theora Ogg. Developed by the Xiph.Org Foundation. Supported by HTML5.
WebM .webm WebM. Developed by the web giants, Mozilla, Opera, Adobe, and Google. Supported by
HTML5.
MPEG-4 .mp4 MP4. Developed by the Moving Pictures Expert Group. Based on QuickTime. Commonly used
or MP4 in newer video cameras and TV hardware. Supported by all HTML5 browsers. Recommended
by YouTube.
Multimedia Formats
70
Browser Support of HTML 5
72
XHTML
What Is XHTML?
• XHTML stands for eXtensible HyperText Markup Language
• XHTML is almost identical to HTML
• XHTML is stricter than HTML
• XHTML is HTML defined as an XML application
• XHTML is supported by all major browsers
73
Difference between HTML and XHTML
<html>
<head>
<title>This is bad
HTML</title> Ambiguity
<body>
<h1>Bad HTML<p> </p> </h1>
<p>This is a paragraph
</body>
74
Difference between HTML and XHTML
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
76
HTML DOM
When a web page is loaded, the browser
creates a Document Object Model of the
page.
The HTML DOM model is constructed as a
tree of Objects:
77
HTML DOM
The HTML DOM is a standard object model and programming
interface for HTML. It defines:
The HTML elements as objects
The properties of all HTML elements
The methods to access all HTML elements
The events for all HTML elements
In other words: The HTML DOM is a standard for how to get,
change, add, or delete HTML elements.
78
1.8 Practice
79
Self-Exercises
80