Académique Documents
Professionnel Documents
Culture Documents
Web Development
HTML documents
<footer> J
<p>Created by <a
href="http://www.udm.ac.mu/">UDM</a></p>
</footer>
</body>
</html>
HTML elements
In this example there are two heading 1 tags; an
opening tag <h1> and a closing tag </h1>.
There is text content nested within these tags.
<h1>HTML5 Document Structure
Example</h1>
The tags are not seen by the viewer of the web
page, but every web browser knows that the text
between the tags is a heading 1.
The pair of tags is referred to as an html
element. So in this case we have a heading 1
element. Web pages are built upon the
6
arrangement of these elements.
HTML Elements
• A. Doctype. This line instructs the browser to interpret all the code that follows
according to a unique set of rules.
B. HTML element. This element nests all the following elements and tells the
browser to expect an HTML document.
C. Head element. This section includes information about the page, but nothing is
rendered on the page itself.
D.Meta element. Provides metadata about the HTML document. Metadata will not be
displayed on the page, but will be machine parsable. Meta elements are typically
used to specify page description, keywords, author of the document, last modified,
and other metadata
• E. Title element. Any content inside the title tags show up at the top of the browser.
This is what is used when a user bookmarks a page in the browser.
F. Body element. All content within the body can be rendered in the browser’s main
window.
G. Header element. Represents a container for introductory content or a set of
navigational links
• H. Heading1 element. Formats the enclosed content as bold by default.
I. Paragraph element. By default, the browser adds space before and after this
element which often contains multiple lines of text.
J. Footer element. Defines a footer for a document or section.
7
HTML 4.0 and XHTML 1.0
8
Examples of differences
between HTML 4.01
and XHTML 1.0
In XHTML, all tags must be lowercase.
XHTML requires all tags to be closed — meaning that
there must be a tag at the start and end of the element
being tagged — such as a headline, paragraph, or
image.
XHTML requires proper nesting of tags. In the
following example, the <em> tag to emphasize text
opens within the <h1> headline tag. As such, it must
be closed before the <h1> is closed.
9
DOCTYPE
The DOCTYPE is the very first line in your document. A
web browser renders all of your page elements based on
the specification you declare.
The web browser checks to see what language you
are using via the DOCTYPE
This is a typical DOCTYPE for HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML
4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
This is a typical DOCTYPE for HTML 5
<!DOCTYPE html>
10
Having a DOCTYPE allows you
to validate your page syntax
You can validate your page syntax based on
the “rules” of the DOCTYPE you have
specified.
For example, the rules of XHTML 1.0 state that
all tags must be lower case. This code, then,
would be invalid:
<H1> Hello! </H1>
The W3C provides a validation service. You
can use it to test your pages. Locating invalid
code is a fast way to check your pages for
errors including typos or missing tags. 11
W3C validator
12
CSS Validator
• The CSS validator checks Cascading Style Sheets (CSS) and (X)HTML documents that
use CSS stylesheets.
• Unicorn
– Unicorn is W3C's unified validator, which helps people improve the quality of their
Web pages by performing a variety of checks. Unicorn gathers the results of the
popular HTML and CSS validators, as well as other useful services, such as
RSS/Atom feeds and http headers.
• Link Checker
– The W3C Link Checker looks for issues in links, anchors and referenced objects in a
Web page, CSS style sheet, or recursively on a whole Web site. For best results, it is
recommended to first ensure that the documents checked use valid HTML
Markup and CSS.
• Internationalization Checker
– The W3C Internationalization Checker provides information about various
internationalization-related aspects of your page, including the HTTP headers that
affect it. It will also report a number of issues and offer advice about how to resolve
them.
• W3C cheatsheet provides quick access to useful information from a variety of
specifications published by W3C. It aims at giving in a very compact and mobile-friendly
format a compilation of useful knowledge extracted from W3C specifications, completed
by summaries of guidelines developed at W3C, in particular Web accessibility guidelines,
the Mobile Web Best Practices, and a number of internationalization tips.
Creating HTML
• Exists between
<head> </head>
tags.
• <title>web
design</title>
<h1>A heading</h1>
<p>A paragraph.</p>
</body>
</html>
Comments: <!-- --> tag
<!DOCTYPE html>
<html>
<head>
<!-- You should put your name between title tags -->
<title>Your name Here</title>
</head>
</html>
<body> Section: Introduction
<body>
<h1>Good morning</h1>
</body>
Exercise 1
<!DOCTYPE html>
<html>
<head>
<title>HTML home page</title>
</head>
<body>
<h1>Good morning</h1>
</body>
</html>
<body> Section: Text Styling
<b></b> bold
• Tags modify the text
<i></i> italicized
between the opening tag <u></u> underlined
and the closing tag. <sup></sup> superscript
– Ex. <b>Hello <sub></sub> subscript
World</b> makes “Hello <strong></strong> strong
World” bold. <em></em> emphasized
<pre></pre> Preformatted
text
<blockquote> Quoted text
</blockquote> block
<!DOCTYPE html>
<html>
<head>
<title>HTML home page</title>
</head>
<body>
<h1>Notice</h1>
<p>This is a <em>bare-minimum</em> web page. It is created
using web standards.</p>
<p>Next paragraph.</p>
<h2>More Info</h2>
<p>This is a paragraph<br>Next line.</p>
</body>
</html>
• Add an image:
<img src=http://udm.ac.mu/icons/front.jpg />
• There are a number of attributes:
Ex. <img src="./logo.jpg" alt="PHP logo" />
• Apple o Apple
• Orange o Orange
Apple
• Pear o Pear
Orange
View the browser Pear
output of
unorderedlists.html
Nested Bulleted List
• Example:
Creates a new row
<table border=1>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
Creates a
<tr> new row
<td colspan=2>That’s a wrap</td>
</tr>
</table> View the browser output of tables.html
<body> Section: <table> tags
Table Data “cells” (<td>) can contain tables (tables within tables):
<table border=1>
<tr>
<td>Contact:</td>
<td>
<table border=1>
<tr>
<td>First Name</td>
<td>Last Name</td>
</tr>
</table>
</td>
</tr>
</table>
View the browser output of tables2.html
<body> Section: <div> tag
• Acts as a <p>
<div style="color:#0000FF">
<h3>This is a heading in a div element</h3>
<p>This is some text in a div element.</p>
</div>
• See www.htmlhelp.com/reference/html40/olist.html
for a list of HTML tags and attributes.
• http://www.w3schools.com/tags/default.asp