Professional Documents
Culture Documents
3
New Semantic Elements − These are like <header>,
<footer>, and <section>.
<em> element
• In this example, the <em> and <h1> elements overlap • Empty elements have a slash before the closing
– It isn’t clear if the <em> element is part of the <h1> element. angle bracket, but HTML5 allows omitting the
slash.
• <hr/> - horizontal rule, <br/> - line break
11 12
<a href="http://www.w3.org/"> <img src="logo.png" alt="Company Logo" />
The World Wide Web Consortium
</a>
• Elements can feature several attributes
• Attributes tell us extra information about elements
• This <img/> element has
• In this example href is an attribute
– A src attribute with a value of logo.png
– It tells us the address of the web page that the text will link to
– An alt attribute with a value of Company Logo
• Attributes always have the same structure.
name="value"
13 14
<!DOCTYPE html>
<html lang="en"> • The document type declaration specifies the version of
<head> HTML that the page uses
<title>Add a title here</title>
<meta charset=utf-8" /> <!DOCTYPE html>
</head> <html lang="en">
<body> <head>
<p>Add some content here.</p> <title>Add a title here</title>
</body> <meta charset=utf-8" />
</html> </head>
<body>
<p>Add some content here.</p>
</body>
</html>
15 16
• There many different versions of (X)HTML including:
– HTML 4.01 • We will the new HTML5 Standard.
– XHTML 1.0 Strict
– HTML5
– XHTML is eXtensible HyperText Markup Language
– It is HTML re-written to conform to the rules of XML.
– It has stricter syntax than HTML.
– HTML5, current version used.
– Syntax rules not as strict as XHTML
– Has more features that improve HTML capabilities.
17 18
• The root element <html> encloses all other elements • The <head> element provides information about the
document.
• lang attribute
<!DOCTYPE html>
– This attribute specifies the language used to write the <html lang="en">
document. <head>
<title>Add a title here</title>
<meta charset=utf-8" />
– It is important for accessibility applications (e.g. screen </head>
readers) and search engines. …
</html>
<!DOCTYPE html>
<html lang="en">
…
</html>
19 20
• The <title> element specifies the page title • Meta data <meta /> is used to specify information
– Visible in the browser’s title bar/tab. about the document.
– Metadata is not displayed.
– Is the text identifying a page when users add your page to their – In this example, the meta element is used to specify the
list of Favorites or Bookmarks. character encoding and author.
</head>
21 22
24
Blank slide
Semantic elements are elements with a meaning.
To the web developer and web browser.
•
<header> - Defines a header
(introductory content) for a document or
a section
•
<nav> - Defines a container for
navigation links, a block of links.
•
<section> - Defines a section in a
document.
•
<article> - Defines an independent self-
contained article e.g. forum posts
•
<aside> - Defines content aside from the
content (like a sidebar), should be
related.
•
<footer> - Defines a footer for a
document or a section e.g. copyright
information, author
•
<main> - Defines main content of a
page, unique content. Only 1 per page.
<!– This is a comment-->
32
• Inline elements <h2>List of dams in Botswana</h2>
– can appear within block-level or other inline elements.
– They take up the width of their contents.
• There are six different levels of heading
– Heading element h1 is considered the most significant heading
– Content model: Generally, inline elements may contain only data and is rendered in the largest font
and other inline elements.
– Each successive heading element (i.e., h2, h3, etc.) is rendered
in a progressively smaller font
– Formatting: By default, inline elements do not begin with new
line.
– Examples: <td>, <a>, <img> • Headings should appear in the correct order.
– A <h3> shouldn’t appear before a <h1>
33 34
1
2 <!DOCTYPE html>
3
29
35 6
<p> • The <blockquote> element is used to define a
The purpose of this page is to demonstrate a basic quotation.
HTML document.
– Browsers usually indent <blockquote> elements.
</p>
– In HTML, the <blockquote> must contain other block-level
elements.
• The <p> element defines a paragraph. – The cite attribute is used to indicate the source of a quote
• When a browser displays a paragraph, it adds a new line • In this example
http://www.w3.org/WAI/intro/accessibility.php
before the paragraph.
<blockquote cite="http://www.w3.org/WAI/intro/accessibility.php">
• Paragraphs should not be nested inside other <p> It is essential that the Web be accessible in order to
provide equal access and equal opportunity to
paragraphs. people with disabilities.
</p>
</blockquote>
37 38
• Inline elements are used to markup small portions of • HTML used to feature many ‘physical style’ tags
text. – Tags such as font specify the colour, typeface and size of text.
• Inline elements must always be nested inside a block • These tags have been ‘deprecated’:
level element. – Will still work in many browsers
– No longer in use
• The <strong> element is used to specify strong
– We shouldn’t use them in our pages! We use CSS.
emphasis.
39 40
Blank slide • HTML5 provides a number of different ways for us to
structure a list of items.
• Unordered list element ul
– creates a list in which each item in the list begins with a bullet
symbol (called a disc), by default.
4
1 42
2 <!DOCTYPE html>
4
5
6 <!-- Fig. 4.8: links2.html -->
7 <!-- Unordered list containing hyperlinks. -->
8 <html>
9 <head>
10 <title>Links</title>
11 </head>
12 <body> Creates an unordered list • The ordered list element ol creates a list in which each
13 <h1>Here are my favorite sites</h1>
14 <p><strong>Click on a name to go to that page.</strong></p> item begins with a number, by default.
15
16 <!-- create an unordered list -->
17 <ul> Makes hyperlinked
18 <!-- add four list items --> elements into Each entry is an li (list item) element.
19 <li><a href = "http://www.deitel.com">Deitel</a></ li>
individual list items
20 <li><a href = "http://www.w3.org">W3C</a></li>
21 <li><a href = "http://www.yahoo.com">Yahoo!</a></li>
22
23
<li><a href = "http://www.cnn.com">CNN</a></li>
</ul>
Other list item markers are : uppercase letters,
24 </body>
25 </html>
lowercase letters, uppercase roman numbers and
lowercase roman numbers.
43 44
List can be displayed horizontally, e.g. To create a
menu. Use CSS.
45 46
49 50
5
1 52
• Validating web pages checks we are using web End
standards.
– Accessibility
– Support standards compliant browsers
– Support a range of devices
5
53 4