XHTML - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

XHTML

Description:

What is XHTML? XHTML stands for Extensible Hypertext Markup Language ... http://validator.w3.org/ is an HTML form for checking (but not fixing) HTML and XHTML ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 15
Provided by: davidma75
Category:
Tags: xhtml | does | for | http | stand | what

less

Transcript and Presenter's Notes

Title: XHTML


1
XHTML
  • http//www.w3schools.com/xhtml/

2
What is XHTML?
  • XHTML stands for Extensible Hypertext Markup
    Language
  • XHTML is aimed to replace HTML
  • XHTML is almost identical to HTML 4.01
  • XHTML is a stricter and cleaner version of HTML
  • XML (Extensible Markup Language) is a markup
    language designed for describing data
  • XHTML is HTML redefined as an XML application
  • XHTML is a bridge between HTML and XML

3
The problem with HTML
  • HTML started out as a way of way of describing
    the structure of documents, with tags to indicate
    headers, paragraphs, and the like
  • Because people wanted to control the appearance
    of documents, HTML acquired tags to control
    fonts, alignment, etc.
  • The result is a markup language that does both,
    but isnt very good at either

4
HTML vs. XML
XML looks a lot like HTML, but--
HTML uses a fixed set of tags
With XML you make up your own tags (and define
what they mean in a separate document)
HTML is designed to display data to humans
XML is designed to describe data to computers
Browsers are very tolerant of errors in HTML
XML documents must be well-formed (syntactically
correct)
All browsers can display HTML
All modern browsers display XML, but in various
ways
5
From HTML to XHTML, I
  • XHTML elements must be properly nested
  • ltbgtltigtbold and italiclt/bgtlt/igt is wrong
  • XHTML documents must be well-formed
  • lthtmlgtltheadgt ... lt/headgtltbodygt ...
    lt/bodygtlt/htmlgt
  • Tag names must be in lowercase
  • All XHTML elements must be closed
  • If an HTML tag is not a container, close it like
    thisltbr /gt, lthr /gt, ltimg src"smile.gif" /gt
  • Note Some older browsers require a space before
    the /

6
From HTML to XHTML, II
  • Attribute names must also be in lower case
  • Example lttable width"100"gt
  • Attribute values must be quoted
  • Example lttable width"100"gt
  • Attribute minimization is forbidden
  • Example ltframe noresize"noresize"gt,cannot be
    abbreviated to ltframe noresizegt
  • The id attribute replaces the name attribute
  • Wrong ltimg src"picture.gif" name"picture1" /gt
  • Right ltimg src"picture.gif" id"picture1" /gt
  • Best ltimg src"picture.gif" name"picture1"
    id"picture1" /gt

7
SGML and DTDs
  • SGML stands for Standard Generalized Markup
    Language
  • HTML, XHTML, XML and many other markup languages
    are defined in SGML
  • A DTD, or Document Type Definition describes
    the syntax to use for the current document
  • There are three different DTDs for XHTML--you can
    pick the one you want
  • These DTDs are public and on the web
  • You must start your XHTML document with a
    reference to one of these DTDs

8
DOCTYPE declaration, I
  • Every XHTML document must begin with one of the
    DOCTYPE declarations (DTDs)
  • lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Strict//EN" "http//www.w3.org/TR/xhtml1/DTD/xhtml
    1-strict.dtd"gt
  • lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "http//www.w3.org/TR/xhtml1/DTD
    /xhtml1-transitional.dtd"gt
  • lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Frameset//EN" "http//www.w3.org/TR/xhtml1/DTD/xht
    ml1-frameset.dtd"gt
  • lt!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
    1.1//EN "http//www.w3.org/TR/xhtml11/DTD/xhtml1
    1.dtd"gt
  • (Essentially the same as XHTML 1.0 Strict)

9
DOCTYPE declaration, II
  • The main DTDs are as follows
  • 1.0 Strict
  • Use for really clean markup, with no display
    information (no font, color, or size information)
  • Use with CSS (Cascading Style Sheets) if you want
    to define how the document should look
  • 1.0 Transitional
  • Use with standard HTML and/or with CSS
  • Allows deprecated HTML elements
  • 1.0 Frameset
  • Use if your document uses HTML frames
  • 1.1
  • Like 1.0 Strict, but with added support for
    Chinese

10
An XHTML Example
  • lt!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0
    Strict//EN" "http//www.w3.org/TR/xhtml1/DTD/xhtml
    1-strict.dtd"gtlthtml xmlns"http//www.w3.org/1999
    /xhtml" xmllang"en"
    lang"en"gt ltheadgt lttitlegtA simple
    documentlt/titlegt lt/headgt ltbodygt
    ltpgtA simple paragraph.lt/pgt lt/bodygtlt/htmlgt

11
Extension
  • A file containing an HTML page should have the
    extension .html
  • According to W3C, an XHTML page should have the
    extension .xhtml
  • However...
  • I have had trouble getting JavaScript to work on
    pages with this extension
  • I recommend sticking with .html, at least for now

12
Tools
  • Dave Raggett's HTML TIDY,http//tidy.sourceforge.
    net/,is a free UNIX tool for checking and
    cleaning up HTML pages
  • The W3C HTML Validation Toolhttp//validator.w3.o
    rg/ is an HTML form for checking (but not fixing)
    HTML and XHTML documents

13
Vocabulary
  • SGML Standard Generalized Markup Language
  • HTML Hypertext Markup Language
  • XHTML eXtensible Hypertext Markup Language
  • XML eXtensible Markup Language
  • DTD Document Type Definition

14
The End
Write a Comment
User Comments (0)
About PowerShow.com