XHTML

  Home  Computer Programming  XHTML


“Learn basic and advance XHTML with hundreds of XHTML Interview Questions and Answers and examples.”



26 XHTML Questions And Answers

21⟩ 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.

 180 views

22⟩ 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>

 188 views

23⟩ 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="rendc.org">

<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="rendc.org"/>

<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.

 188 views

24⟩ 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 rendc.org/html</h1>

 186 views

25⟩ 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="rendc.org"/> - Two attributes: ► <img src="ggl.gif" alt="ggl"/> - Two attributes: "src" and "alt".

 195 views

26⟩ 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.

 178 views