XHTML - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

XHTML Structure

XHTML Structure

shape Introduction

This chapter demonstrates about the XHTML Structure which have the complete structure about the document following are the concepts are covered in this chapter.
  • Doctypes
  • XHTML Syntax

Doctypes

shape Description

Document Type Definitions (DTDs) defines the  XHTML standard. The most ordinarily utilized and simple one is the XHTML Transitional report. Following are the three Document Type Definitions correspond to Three DTDs.
  • Strict
  • Transitional
  • Frameset
There are some XHTML elements and attributes, these are accessible in one DTD yet not accessible in another DTD. In this manner, while composing XHTML report, user should choose  XHTML elements or attributes.Valid and invalid elements and attributes are recognized by XHTML validator. Strict If user planning to utilize Cascading Style Sheet (CSS) entirely and keeping away from to compose the majority of the XHTML attributes, then which is prescribed to utilize these DTD. DTD conforms whether the document is best quality or not. If user needs to use XHTML 1.0 Transitional DTD then user can include one line in XHTML Document which is shown below. [html] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [/html] Transitional If user wants to utilize numerous XHTML attributes and additionally few Cascading Style Sheet properties, then user ought to receive the DTD and user ought to compose XHTML Document in accordingly. If user need to use XHTML 1.0 Transitional DTD then user can include one line in the XHTML Document which is shown below. [html] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [/html] Frameset User can use the HTML Frames when user need to partition the browser window into two or more frames. If user need to use XHTML 1.0 Transitional DTD then user can include one line in the XHTML Document which is shown below. [html] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> [/html]

XHTML Syntax

shape Description

XHTML syntax is fundamentally the same as HTML syntax structure and all valid HTML elements also get validate in XHTML too. If user composing a XHTML record, user need to give careful consideration to make the HTML document consistent to XHTML. Following are the some points to remember while constructing XHTML Document. Doctype Declaration Similar to HTML All XHTML documents must present a DOCTYPE declaration at the top. There are three sorts of DOCTYPE declarations thise are alreday shown in the example below demonstrates the Doctype. [html] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> [/html] Case sensitive XHTML is case touchy markup dialect. All XHTML labels and credits should be composed in lower case as it were. [html] <!-- This is invalid in XHTML --> <A Href="/xhtml/xhtml_tutorial.html">XHTML Tutorial</A> <!-- Correct XHTML way of writing this is as follows --> <a href="/xhtml/xhtml_tutorial.html">XHTML Tutorial</a> [/html] Closing tags Every XHTML tag ought to has a equal closing tags, even empty elements should maintain closing tags. The snippet below demonstrates the proper and un proper way of using tags. [html] <!-- This is invalid in XHTML --> <p>This paragraph is not written according to XHTML syntax. <!-- This is also invalid in XHTML --> <img src="/images/xhtml.gif" > [/html] The snippet below demonstrates the proper way of using tags. [html] <!-- This is valid in XHTML --> <p>This paragraph is not written according to XHTML syntax.</p> <!-- This is also valid now --> <img src="/images/xhtml.gif" /> [/html] Attributes Quotes Each values of XHTML attribute can be Quoted.Otherwise,the document is treated as an invalid. The snippet below demonstrates the syntax. [html] <!-- This is invalid in XHTML --> <img src="/images/xhtml.gif" width=250 height=50 /> <!-- Correct XHTML way of writing this is as follows --> <img src="/images/xhtml.gif" width="250" height="50" /> [/html] The id Attribute The id attribute can replaces the name characteristic. Rather than utilizing name = "name", XHTML likes to utilize id = "id". The snippet below demonstrates the id attribute. [html] <!-- This is invalid in XHTML --> <img src="/images/xhtml.gif" name="xhtml_logo" /> <!-- Correct XHTML way of writing this is as follows --> <img src="/images/xhtml.gif" id="xhtml_logo" /> [/html] The Language Attribute The language attribute of the script tag is deprecated. The snippet below demonstrates language attribute. [html] <!-- This is invalid in XHTML --> <script language="JavaScript" type="text/JavaScript"> document.write("Hello XHTML!"); </script> <!-- Correct XHTML way of writing this is as follows --> <script type="text/JavaScript"> document.write("Hello XHTML!"); </script> [/html] Nested Tags User should settle all the XHTML tags appropriately. Generally user document is an incorrect XHTML document. The snippet below demonstrates the Nested tags. [html] <!-- This is invalid in XHTML --> <b><i> This text is bold and italic</b></i> <!-- Correct XHTML way of writing this is as follows --> <b><i> This text is bold and italic</i></b> [/html]

Summary

shape Points

  • DTDs define the XHTML standards.
  • User can partition the browser window by using Frames.
  • User need to use the closing tags properly in XHTML.