1. What Is an XHTML Element Attribute?

An element attribute is a predefined property about this element. Element attributes allows you to provide additional information to the element. Most XHTML elements have some common attributes. But many XHTML elements have their own specific attributes.

Here are some good examples of element attributes:

► <br/> - No attribute.
► <script type="text/javascript"> - One attribute: "type".
► <p class="sideNote"> - One attribute: "class".
► <meta name="Author" content="globalguideline.com"/> - Two attributes: ► <img src="ggl.gif" alt="ggl"/> - Two attributes: "src" and "alt".

2. Is XHTML Element Name Case Sensitive?

Yes, XHTML element names are case sensitive. All element names must be written in lower case letters.

Here are some valid and invalid XHTML element names:

► <html> - Valid name.
► <HTML> - Invalid name, must use lower case letters.
► <xhtml> - Invalid name, not defined by XHTML specification.
► <Body> - Invalid name, must use lower case letters.

Note to HTML document authors: HTML element names are not case sensitive. But XHTML element names are case sensitive. If you are converting existing HTML documents to XHTML documents, you will get a lots of syntax errors about upper case letters used in HTML tags.

3. How To Enter Element Content?

Most of XHML elements allow you to specify contents. But there are some XHTML elements that do not allow any contents. If an XHTML element does allow element content, you need to enter the content between the opening tag and the closing tag.

Here are some good examples of XHTML elements with contents:

► <title>My First XHTML Document</title>
► <p>A very long paragraph...</p>
► <h1>XHTML Tutorials by globalguideline.com/html</h1>

4. What Is Wrong with My <meta> Tags?

If you are converting existing HTML documents to XHTML format, you may find some <meta> tags are written as:

<meta name="Author" content="globalguideline.com">
<meta name="Description"
content="Tutorials, FAQs and Tips on XHTML Documents.">
<meta name="Keywords"
content="XHTML Tutorials, FAQs, Tips">

But all those <meta> tags are invalid in a XHTML document. They must be closed as:

<meta name="Author" content="globalguideline.com"/>
<meta name="Description"
content="Tutorials, FAQs and Tips on XHTML Documents."/>
<meta name="Keywords"
content="XHTML Tutorials, FAQs, Tips"/>

Note to HTML document authors: <meta> tag syntax in XHTML is the opposite to <meta> tag syntax in HTML. In XHTML, meta tag must be closed. But in HTML, meta tag can not be closed.

5. What Is Wrong with My <br> Tags?

If you are used HTML syntax, you may write your <br> tags as in the paragraph below:

<p>
I love the way you look at me,<br>
Your eyes so bright and blue.<br>
I love the way you kiss me,<br>
Your lips so soft and smooth.<br>
</p>

But that paragraph will be invalid as XHTML documents, because all 4 <br> are not closed. You should change it to:

<p>
I love the way you look at me,<br/>
Your eyes so bright and blue.<br/>
I love the way you kiss me,<br/>
Your lips so soft and smooth.<br/>
</p>

6. How To Close an XHTML Element?

Every XHTML element must be closed. There are two ways to close an XHTML element:

► Using a closing tag, which is the element name prefixed with "/" and enclosed in a pair of angle brackets: "<" and ">".
► Closing the opening tag immediately by placing "/" before the ending bracket: ">".

Here are some good examples of closing XHTML elements:
► <html>...</html>- Closing the html element with a closing tag.
► <head>...</head> - Closing the head element with a closing tag.
► <title/> - Closing the title element immediately with no content.
► <body>...</body> - Closing the body element with a closing tag.
► <p>...</p> - Closing the p element with a closing tag.
► <script/> - Closing the script element immediately with no content.

7. How To Write the Opening Tag of an XHTML Element?

When you are writing an XHTML element, you must start with its opening tag, which contains the name of the element and attributes if needed. The opening tag is enclosed in a pair of angle brackets: "<" and ">".

XHTML element names are predefined by the XHTML specification. You can not make up your own tag names. Here are some good examples of XHTML element opening tags:

► <html> - Opening tag of the html element.
► <head> - Opening tag of the head element.
► <title> - Opening tag of the title element.
► <body> - Opening tag of the body element.
► <p> - Opening tag of the p element.
► <script> - Opening tag of the script element.

8. How To Enter Comments into XHTML Documents?

If you want to enter comments into an XHTML document, you can use the comment tag: "<!-- ... -->".

Here are some good examples of XHTML comments:

<!-- Start north banner -->...

<script type="text/javascript">
<!-- alert("Are you ok?"); -->
</script>...

<!-- A long ...
paragraph ...
of comments -->...

9. What Is an XHTML Element?

An XHTML element is the basic building block of an XHTML document. An XHTML element has the following features:

► An XHTML element must have a name.
► An XHTML element may have zero or more attributes.
► An XHTML element may or may not have any content.

Here is a good example of an XHTML element:

<a href="http://www.globalguideline.com/">globalguideline.com</a>

The above an XHTML element has:

► A name called "a", which is coded at the beginning of the opening tag.
► An attribute called "href", which is coded inside the opening tag. It also has a value specified after the "=" sign.
► A string of text as the content, which is coded between the opening tag and closing tag.

10. What Tools to Use to View XHTML Documents?

The basic tool you need to view XHTML documents is any Web browser, like Internet Explorer (IE) or FireFox.

The following tutorial shows you how to view a XHTML document with :

► Write an XHTML document and save it as hello.html.
► Run IE and select the File > Open menu. The Open dialog box shows up.
► Use the Browse button to find and select your XHTML document, hello.html.
► Click OK, IE will open hello.html and let you view it.

Here is a how your XHTML document, hello.html, will look like if viewing it with IE:
Hello in IE

Download Interview PDF