120 likes | 228 Views
XHTML. Chapter 12. Extensible HyperText Markup Language. stricter syntax, based on the requirements of XML XHTML syntax looks much like HTML syntax XHTML documents can be processed automatically using any standard XML library. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
E N D
XHTML Chapter 12
Extensible HyperText Markup Language. • stricter syntax, based on the requirements of XML • XHTML syntax looks much like HTML syntax • XHTML documents can be processed automatically using any standard XML library
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <HTML LANG="en"> <HEAD> <TITLE>A simple HTML document</TITLE> </HEAD> <BODY> <P>Hello world! <BR> Can anybody hear me? </BODY> </HTML>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <htmlxmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>A simple XHTML document</title> </head> <body> <p>Hello world! <br /> Can anybody hear me?</p> </body> </html>
Why XHTML? • Web content is delivered to more devices than conventional computers • HTML’s flexibility sometimes meant that the document structures they needed to manipulate looked a little different than expected • XHTML’sXML compatibility made it easy to use these tools on XHTML • XHTML encourages greater consistency among documents
Why XHTML? • W3C was hoping that moving to an XML foundation would let developers create custom vocabularies for mixing with the classic HTML vocabulary • XHTML could also be mixed in to other XML vocabularies
XHTML and XML Namespaces • XML is incredibly generic • XHTML without any other vocabularies mixed in, the namespace is declared on the html element using the XHTML attribute xmlns • <htmlxmlns="http://www.w3.org/1999/xhtml" >
XHTML Versions • XHTML 1.0 has the same contents as HTML 4.01, • XHTML 1.1 is a module-based reformatted version of the 1.0 release • XHTML 2.0 Working Draft is controversial because it breaks backward compatibility with all previous versions
Document Types • XHTML 1.0 Strict • XHTML 1.0 Transitional • XHTML 1.0 Frameset • XHTML 1.1 • XHTML 2.0
Validation Tools • Example 12-2. Adding a validation link as validate.html
Generating XHTML with PHP • Generating XHTML fromyour PHP code is no more difficult than creating plain old HTML • Example 12-4. Creating an XHTML document from PHP