Chapter 12. XHTML

Now that you’ve learned the foundations of using PHP and MySQL to build dynamic pages, take some time to explore improvements to the HTML markup that forms the basis of your web pages. You’ll learn about XHTML, what it demands, and why it’s worth the extra effort to produce. Remember that in order to produce quality web content from your PHP scripts, the markup must be standards-conformant. Think of the XHTML output as the finished product in the process of requesting a page after PHP and a database functions process. We’ll also discuss validating the XHTML output that your scripts produce to catch any errors.

XHTML stands for Extensible HyperText Markup Language. XHTML is a markup language that is similar to HTML, but with a stricter syntax, based on the requirements of XML. HTML was built on SGML, which is flexible but complex to process, and XML stripped down SGML to make it easier to process if a bit less flexible. XHTML syntax looks much like HTML syntax, using greater- and less-than signs (< and >) to define tags, but has much stricter requirements for how those tags are deployed. XHTML documents that meet those syntactic requirements are called well-formed, while XHTML documents that meet the syntax plus the structural rules contained in the DTDs are called valid.

Tip

Plain old HTML documents can be valid, too—they don’t have to meet XML’s syntactic rules, but they do have to live up to the structures defined in the various HTML specs.

XHTML documents can be ...

Get Learning PHP & MySQL, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.