working with xhtml l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Working with XHTML PowerPoint Presentation
Download Presentation
Working with XHTML

Loading in 2 Seconds...

play fullscreen
1 / 34

Working with XHTML - PowerPoint PPT Presentation


  • 137 Views
  • Uploaded on

Working with XHTML. Tutorial 9. Creating a Well-Formed Valid Document. Objectives. Introducing XHTML Creating a Well-Formed Document Creating a Valid Document Creating an XHTML Document Testing an XHTML Document Using Style Sheets and XHTML. Introducing XHTML.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Working with XHTML' - thisbe


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
working with xhtml

Working with XHTML

Tutorial 9

Creating a Well-Formed Valid Document

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

objectives
Objectives
  • Introducing XHTML
  • Creating a Well-Formed Document
  • Creating a Valid Document
  • Creating an XHTML Document
  • Testing an XHTML Document
  • Using Style Sheets and XHTML

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

introducing xhtml
Introducing XHTML
  • SGML (Standard Generalized Markup Language)
    • can be used with almost any type of document stored in almost any format
    • Introduced in the 1980s
    • Metalanguage– used to created other languages
  • HTML
    • standards get confusing among browsers
    • can be applied inconsistently

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

introducing xhtml4
Introducing XHTML
  • XML (Extensible Markup Language)
    • used to design markup languages
  • XML documents must be evaluated with an XML parser
  • An XML document with correct syntax is a well-formed document
  • A well-formed document with correct content and structure is a valid document
  • DTD specifies correct content and structure

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

introducing xhtml5
Introducing XHTML
  • XHTML is a reformulation of HTML, written in XML

Versions of XHTML

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

dtds associated with xhtml 1 0
DTDs associated with XHTML 1.0

- transitional: supports many of the presentational features of HTML, including the deprecated elements and attributes Best used for older documents that contain deprecated features

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

dtds associated with xhtml 1 07
DTDs associated with XHTML 1.0

- frameset: used for documents containing frames, and also supports deprecated elements and attributes

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

dtds associated with xhtml 1 08
DTDs associated with XHTML 1.0

- strict: does not allow any presentational features or deprecated HTML elements and attributes. Does not support frames or inline frames. It is best used for documents that need to strictly conform to the latest standards.

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

creating a well formed document
Creating a Well-Formed Document

Rules for well-formed XHTML documents

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

creating a well formed document10
Creating a Well-Formed Document
  • XHTML documents must also include a single root element that contains all other elements
    • For XHTML, that root element is the html element
  • Attribute minimization is when some attributes lack attribute values
    • XHTML doesn’t allow attribute minimization

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

attribute minimization in html and xhtml
Attribute minimization in HTML and XHTML

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

creating a valid document
Creating a Valid Document
  • The DTD used depends on the content of the document and the needs of your users
  • To support old browsers, use the transitional DTD
  • To support old browsers in a framed Web site, use the frameset DTD
  • To support more current browsers and want to weed out any use of deprecated features, use the strict DTD

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

creating a valid document13
Creating a Valid Document
  • Elements not allowed under the strict DTD:
    • applet - isindex
    • basefont - menu
    • center - s
    • dir - strike
    • font - u
    • iframe

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

creating a valid document14
Creating a Valid Document
  • Some attributes are restricted, while others are required in XHTML

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

attributes prohibited in the strict dtd
Attributes prohibited in the strict DTD

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

required xhtml attributes
Required XHTML attributes

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

creating an xhtml document
Creating an XHTML Document
  • The first line of an XTHML document should contain a declaration indicating that the document adheres to the rules and syntax of XML
  • XML (and thus XHTML) documents are based on a character set
    • A character set is a set of abstract symbols matched to code numbers

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

character sets
Character Sets
  • Universal Character Set (UCS)
  • Unicode
  • Character encoding is the process in which bytes are translated back into characters (when a document is sent across the Internet)

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

adding an xml declaration
Adding an xml Declaration
  • To declare that a document is written in XML, enter the following as the first line of the file:
    • <?xml version=“value” encoding=“type” standalone=“type” ?>
    • Where the version attribute indicates the XML version of the document, the encoding attribute specifies the character encoding, and the standalone attribute indicates whether the document contains references to an external DTD.

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

adding an xml declaration20
Adding an xml Declaration
  • For XHTML documents, use the declaration:
    • <?xml version=“1.0” encoding=“UTF-8” standalone=“no” ?>

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

the xml declaration
The XML Declaration
  • You can also add the DOCTYPE declaration, which tells XML parsers what DTD is associated with the document
  • <!DOCTYPE root type “id” “url”>

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

the xml namespace
The xml Namespace
  • A namespace is a unique identifier for elements and attributes originating from a particular document type (like XHTML or MathML)
  • Two types of namespaces:
    • default: applied to a root element and any element within it
    • <root xmlns=“namespace”>

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

the xml namespace23
The xml Namespace
  • local: applies to only select elements
    • - Each element in the local namespace is marked by a prefix attached to the element name
    • xmlns: prefix=“namespace”
    • Identify any element belonging to that namespace by modifying the element name in the tag:
      • prefix:element

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

setting the xhtml namespace
Setting the XHTML Namespace
  • To set XHTML as the default namespace for a document, add the xmlns attribute to the html element with the following value:
    • <html xmlns=http://www.w3.org/1999/xhtml>

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

testing an xhtml document
Testing an XHTML Document
  • To test your document, you need to send the file to an XML parser or an XHTML validator
  • Sometimes the same mistake results in several errors are noted in the report
    • - fixing one mistake can solve several errors

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

fixing the errors in the paragraph elements
Fixing the errors in the paragraph elements

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

report showing a successful validation under xhtml 1 0 transitional
Report showing a successful validation under XHTML 1.0 transitional

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

testing an xhtml document28
Testing an XHTML Document
  • To test under another DTD, you’ll need to change the DOCTYPE declaration

Changing the DOCTYPE declaration to XHTML 1.0 strict

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

using style sheets and xhtml
Using Style Sheets and XHTML
  • Parsed character data (PCDATA) is text parsed by a browser or parser
  • Unparsed character data (CDATA) is text not processed by the browser or parser

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

using style sheets and xhtml30
Using Style Sheets and XHTML
  • A CDATA section marks a block of text as CDATA so that parsers ignore any text within it

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

tips for converting old html code to xhtml
Tips for Converting old HTML Code to XHTML
  • Include an xml declaration in the first line of your file so that your document can be accessed by XML parsers
  • Add a DOCTYPE declaration for one of the XHTML DTDs and check your document for well-formedness and validity whenever you make a change to the code
  • Add the XHTML default namespace to the html element of your document

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

tips for converting old html code to xhtml32
Tips for Converting old HTML Code to XHTML
  • Make sure that all element and attribute names are in lowercase letters and that all attribute values are placed in quotes
  • Make sure that all empty elements are entered as one-sided tags. Look especially for improper syntax in the img, hr, and br elements
  • Make sure that all two-sided tags are properly closed. Old HTML code often does not have closing tags for the p element

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

tips for converting old html code to xhtml33
Tips for Converting old HTML Code to XHTML
  • Make sure that all inline images contain the alt attribute
  • Look for deprecated attributes such as align, bgcolor, and background, and replace them with the float (or text-align), background-color, and background-image styles
  • Replace the name attribute with the id attribute
  • Fix all instances of attribute minimization

New Perspectives on Creating Web Pages with HTML, XHTML, and XML

tips for converting old html code to xhtml34
Tips for Converting old HTML Code to XHTML
  • Replace the use of the font element with either the span element or with a style that applies the same formatting specified by the font element
  • Replace the use of the width attribute in the td or th element with the width style

New Perspectives on Creating Web Pages with HTML, XHTML, and XML