xhtml part1

30

Click here to load reader

Upload: nleesite

Post on 16-May-2015

1.206 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Xhtml Part1

XHTML ReviewPart 1

Instructor: Nancy Lee

Page 2: Xhtml Part1

Course Objectives

To understand important components of XHTML documents.

To use XHTML to create Web pages.To be able to add images to Web pagesTo understand how to create and use

hyperlinks to navigate Web pagesTo be able to mark up lists of information

Page 3: Xhtml Part1

Introduction

Internet is 3 decades old

The internet offers many opportunities

You will develop your own web site in this class

Page 4: Xhtml Part1

Introduction

You will add pages during the semester

We will use XHTML for basic web pages Extensible Hypertext Markup Language

Page 5: Xhtml Part1

Introduction

We will also use CSS to format pages Cascading Style Sheets

XHTML unlike HTML Only content and structure Formatting using CSS

Page 6: Xhtml Part1

Editing XHTML

Write XHTML in source-code form. Type into text editor

Notepad

Files are saved as .html .htm

Page 7: Xhtml Part1

Editing XHTML

XHTML documents are stored on a web server

Test Page by opening in a browser Firefox IE6 Netscape

Page 8: Xhtml Part1

First XHTML Example

main.html

Required to conform to XHTML syntax<?xml version =“1.0”?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"

"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Page 9: Xhtml Part1

First XHTML Example

Comments

<!-- Fig. : main.html -->

<!-- Our first Web page -->

Page 10: Xhtml Part1

First XHTML Example

Element that defines the document

<html xmlns =" http://www.w3.org/1999/xhtml">

</html>

Page 11: Xhtml Part1

First XHTML Example

Head element of document<html xmlns =" http://www.w3.org/1999/xhtml">

<head>

</head>

</html>

Page 12: Xhtml Part1

First XHTML Example

Head element of document Title Style information

<html xmlns =" http://www.w3.org/1999/xhtml">

<head>

<title>Internet and WWW How to Program - Welcome</title>

</head>

</html>

Page 13: Xhtml Part1

First XHTML Example

Body element of document Content and structure

<html xmlns =" http://www.w3.org/1999/xhtml"> <head> <title>Internet and WWW How to Program - Welcome</title> </head> <body>Key line in program: tells browser to display text

Tells browser to display text <p>Welcome to XHTML!</p> </body></html>

Page 14: Xhtml Part1

First XHTML Example

All XHTML documents delimit an element with Start tag

<html> End tag

</html> All XHTML tags must have end tag

Page 15: Xhtml Part1

First XHTML Example

All XHTML documents delimit an element with Start tag

<html xmlns=“ http://www.w3.org/1999/xhtml”> Start tags may have attributes

• Name• Value• Values must be enclosed in “ “• Syntax error if not• Upper case is a syntax error• Separated by = sign

Page 16: Xhtml Part1

First XHTML Example

Documents have two sections Head Body

Nested elements should be indented for readability.

Tags may not overlap

Page 17: Xhtml Part1

W3C XHTML Validation Service

W3C provides a validation service

validator.w3.org

Most browsers will attempt to render XHTML documents even if invalid

Page 18: Xhtml Part1

Headers

header.html

<body>

<h1>Level 1 Header</h1>

<h2>Level 2 header</h2>

<h3>Level 3 header</h3>

<h4>Level 4 header</h4>

<h5>Level 5 header</h5>

<h6>Level 6 header</h6>

</body>

Size may vary by browser

Page 19: Xhtml Part1

Linking

Hyperlink Pages Images Sections

link.html

link2.html

Page 20: Xhtml Part1

Linking

Links are created with the anchor tag

anchor element

<a> </a>

Page 21: Xhtml Part1

Linking

href attributespecifies link to URL<a href =" http://www.yahoo.com">Yahoo!</a>

file <a href =" home.html">Home</a>

e-mail address• uses mailto: URL

<a href =mailto:[email protected]>email me</a>

Page 22: Xhtml Part1

Images

picture.html

Use img element to place pictures on your web page

<img />

Closing slash is required /> or </img>

Page 23: Xhtml Part1

Images

Attributes src

<img src=“picture.jpg” />

Height, Width <img src=“picture.jpg” width=“200” height=“200” />

Image measured in pixels

Page 24: Xhtml Part1

Images

Attributes alt (required in XHTML)<img src=“picture.jpg” width=“200” height=“200” alt=“This is a

picture” />

accessible pages Speech synthesizers use text

Page 25: Xhtml Part1

Images

Nest img element inside of anchor element to create hyperlink using picture.

Used to create buttons

Pictorial links

Thumbnails

Page 26: Xhtml Part1

Images

Non spacing break element does not have ending tag, but is required for XHTML

<br />

Page 27: Xhtml Part1

Images

nav.html

Discuss use of buttons for navigation links

Page 28: Xhtml Part1

Special Characters and More Line Breaks

Some characters are not on keyboard or difficult to type

Symbols may cause syntax error < > =Use &code;Example:

<p> if x < 10 then increment x by 1</p>Causes syntax error

<p> if x &lt; 10 then increment x by 1</p>See Appendix A in text.

Page 29: Xhtml Part1

Unordered Lists

Unordered list element <ul> </ul>

List<li> </li>

Page 30: Xhtml Part1

Nested and Ordered Lists

Ordered and unordered lists may be nested

Example program list.html