Introduction What Is XHTML? Well-Formed XHTML Code

Introduction What Is XHTML? Well-Formed XHTML Code

Introduction to XHTML Introduction Although plain HTML has come a long way, XHTML represents the future of HTML. XHTML better structures HTML to take advantage of many of the features of XML. And best of all, XHTML is compatible with today's newest browsers. What is XHTML? XHTML is HTML markup that follows a more rigorous XML-style formatting and is the standard for HTML development going forward. Today, most browsers still display old or poorly applied HTML. Because it has stricter rules for applying markup, XHTML will, in the long run, provide better performance than HTML, especially for a wider variety of Web-connected devices, including cell phones and handheld devices. Although browser support for HTML will probably not disappear overnight, with a few modifications, you can start applying the XHTML standards in your Web pages right away. Well-formed XHTML code All XHTML Web pages must be well-formed. This means that: Tags and attributes must be lowercase. Unlike HTML, XHTML is case-sensitive. HTML has never been case-sensitive (for instance, the tag <BR> is treated the same as the tag <br>), but HTML 4.0 recommends that HTML elements and attributes be lowercase, and XHTML 1.0 requires lowercase tags. Elements that encapsulate data have beginning and ending tags. Empty elements (meaning tags that don't have ending tags, such as <img> and <br>) use the forward slash at the end of the tag (for example, <img /> or <br />). Tags must be properly nested, as in the following example: <p><strong><emphasis>Some information.</emphasis></strong><br /></p> Notice that the <emphasis> and </emphasis> tags are enclosed within <strong> and </strong> tags, which are contained within the <p> and </p> tags. Also notice that the <br /> tag includes the trailing forward slash (the end tag) within it. Deprecated HTML presentation tags such as <font> must be replaced by CSS All script and style tags should have a type attribute Attribute values must be lower case Attribute values must be surrounded by quotation marks. The alt attribute is required for all images, even if the value is empty (for example, alt=""). Attributes cannot be minimized An example of a minimized attribute is the following: <input checked> The same attribute as well-formed XHTML looks like this: <input checked="checked" /> Finally, one of the following DOCTYPE declarations (DTD) must appear at the top of the page: Strict: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Transitional: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> Frameset: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> Valid XHTML code All XHTML Web pages must be valid. This means that the code has been checked against a formal standard (called a schema) and has met all the requirements of that standard. The standard is defined by the inclusion of a document type declaration (DTD) at the top of the code page before the <html> tag. Although an explicit document type definition declaration is optional in HTML, in XHTML it is required. The XHTML DOCTYPE declaration tells a Web browser what kind of structure (elements and attributes) to expect to find in the page. The following is an example of a DOCTYPE declaration in XHTML 1.0: DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> XHTML 1.0 defines the following three DTDs, which are similar to those in HTML 4.01 and are designed to help migrate existing HTML Web pages to XHTML: Strict: Used for a Web page that uses cascading style sheets (CSS). Most HTML formatting-related attributes (such as align) are not supported in favor of the id, class, and style attributes used with CSS. Transitional: Used for a page that needs to continue to use HTML formatting-related attributes for older browsers that do not support CSS. Frameset: Used for a page that supports frames. For more information on DOCTYPE declarations, see Working with HTML DOCTYPE Declarations. XHTML Web pages require more than a DTD declaration to be valid. You also need to test the validity of your page and fix any coding errors that appear. Luckily, there are online tools available to help you test the validity of your page. After your Web page is ready in XHTML, you can use the W3C Markup Validation Service to identify and resolve and coding errors you might have, or to verify that the XHTML you wrote is indeed valid code. Conclusion XHTML not only combines the best of XML and HTML 4.01, it is the future standard for Web programming. Best of all, because XHTML is still HTML, it is as compatible with older browsers as HTML 4.01. About the author: Jeannine Gailey is owner of Webbish6, author, and Web consultant. .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    2 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us