0% found this document useful (0 votes)
19 views

Extensible Hyper-Text Markup Language (XHTML) Interview Questions and Answers

HTML
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Extensible Hyper-Text Markup Language (XHTML) Interview Questions and Answers

HTML
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 11

Extensible Hyper-Text Markup Language

(XHTML) Interview Questions and Answers


This page contains the collection of Extensible Hyper-Text Markup Language (XHTML)
Interview Questions and Answers / Frequently Asked Questions (FAQs) under category Web
Programming. These questions are collected from various resources like informative websites,
forums, blogs, discussion boards including MSDN and Wikipedia. These listed questions can
surely help in preparing for Extensible Hyper-Text Markup Language (XHTML) interview or
job.

What Is XHTML?
XHTML stands for Extensible Hyper-Text Markup Language. XHTML is a scripting language
that authors can use to embed text tags into a text document to add structural and formatting
information.

More precisely, XHTML gives authors the means to:

► Publish online documents with headings, text, tables, lists, photos, etc.
► Retrieve online information via hypertext links, at the click of a button.
► Design forms for conducting transactions with remote services, for use in searching for
information, making reservations, ordering products, etc.
► Include spread-sheets, video clips, sound clips, and other applications directly in their
documents.

What Does an XHTML Document Look Like?


An XHTML document is a normal text file with predefined tags mixed with the text contents of
the document. Tags are enclosed in pairs of angle brackets: "<" and ">".

Below is how a simple XHTML document will look like if you open it in a text editor:

<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>My First XHTML Document</title>
</head>
<body>
<p>Hello world!</p>
</body>
</html>
What Is the Relation between XHTML and HTML?
HTML (Hyper-Text Markup Language) is the original markup language for writing Web
documents.

XHMTL 1.0 is basically the same language as HTML 4.0. But XHTML 1.0 is defined in XML
1.0 syntax. XHTML 1.0 offers the following features:

► XHTML documents are XML conforming. As such, they are readily viewed, edited, and
validated with standard XML tools.
► XHTML documents can be written to operate as well or better than they did before in existing
HTML 4-conforming user agents as well as in new, XHTML 1.0 conforming user agents.
► XHTML documents can utilize applications (e.g. scripts and applets) that rely upon either the
HTML Document Object Model or the XML Document Object Model.

What Is the Relation between XHTML and XML?


XML (Extensible Markup Language) is a generic markup language to organize generic
information into a structured document with embedded tags.

XHTML is entirely based on XML. You can actually say that XHTML is a child language of
XML.

What Is the Relation between XHTML and the Web?


The Web is a publisher technology based on the Internet to allow publishers to publish hyper
linked documents to be viewed by Internet users.

XHTML is the next generation language that used to compose those hyper linked documents. In
another word, XHTML is the technical language that controls Web page contents and hyper
links.

What Is the Relation between XHTML and HTTP?


HTTP (Hyper-Text Transfer Protocol) is an Internet communication protocol, that allows a
viewer's computer talking to a publisher's computer to fetch XHTML documents.

The viewer's computer issues a HTTP request message to the publisher computer first. Then the
publisher returns a HTTP response message back to the viewer's computer with the requested
XHTML document included in the message.

The following diagram shows how HTTP works with XHTML documents:
HTTP Diagram

What Is the Relation between XHTML and URL?


URL (Uniform Resource Locator) is a compact string representation of the location for a Web
document or other resource that is available on the Internet.

The URL of an XHTML document is usually the document file name prefixed with the domain
name of your Web server and the http protocol name. As soon as you uploaded an XHTML
document to a Web server, that document will have a URL to represent its location on the
Internet. For example, if you have a Web server with domain name like questions-
interviews.com, and you have uploaded an XHTML document called welcome.html, then the
URL of that XHTML document on the Internet is http://www.questions-interviews.com/html

What Is URI?
URI (Uniform Resource Identifier) is a superset of URL. URI provides a simple and extensible
means for identifying a resource in a more generic way. For example, the following strings are
all valid URIs:

ftp://ftp.is.co.za/rfc/rfc1808.txt
http://www.ietf.org/rfc/rfc2396.txt
ldap://[2001:db8::7]/c=GB?objectClass?one
mailto:[email protected]
news:comp.infosystems.www.servers.unix
tel:+1-816-555-1212
telnet://192.0.2.16:80/
urn:oasis:names:specification:docbook:dtd:xml:4.1.2

When an XHTML document is published on the Internet, its location can be represented by a
URL, which is also a URI.

What Is the Relation between XHTML and SGML?


SGML (Standard Generalized Markup Language) is a metalanguage in which one can define
markup languages, like HTML, for documents. SGML is a descendant of IBM's Generalized
Markup Language (GML), developed in the 1960s by Charles Goldfarb, Edward Mosher and
Raymond Lorie (whose surname initials also happen to be GML).

XHTML is not directly related to SGML. But it is indirectly to SGML through HTML.

What Is the Relation between XHTML and CSS?


CSS (Cascading Style Sheets) is a technical specification that allows XHTML document authors
to attach formatting style sheets to XHTML documents. When XHTML documents are viewed
as Web pages through Web browsers, the attached style sheets will alter the default style sheets
embedded in browsers.

What Is the Relation between XHTML and DTD?


DTD (Document Type Definition) is a language based on XML to you to define a specific type
of XML documents.

Since XHTML is a specific type of XML documents, you can use DTD to define the structure of
XHTML. In fact, XHTML 1.0 Strict version is defined in DTD as shown at
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd.
Who Developed XHTML?
XHTML was developed by W3C HTML Working Group with Steven Pemberton as the group
chair.

What Is the Latest XHTML Specification?


The latest XHTML specification is XHTML 1.0 second edition revised in August, 2002 by W3C.
If you are professional XHTML developer, you should get a copy of this specification at
http://www.w3.org/TR/xhtml1/.

How Many Tags Are Defined in XHTML 1.0?


There are 77 tags defined in XHTML 1.0:

a abbr acronym address area b base bdo big blockquote


body br button caption cite code col colgroup dd del
dfn div dl dt em fieldset form h1 h2 h3
h4 h5 h6 head hr html i img input ins
kbd label legend li link map meta noscript object ol
optgroup option p param pre q samp script select small span strong style sub sup table tbody td
textarea tfoot th thead title tr tt ul var

How To Validate XHTML Documents Online?


If you have just finished a new XHTML document, and you want to make sure that confirms
with the XHTML specification, you can use the XHTML online validator at
http://validator.w3.org/.

There are 3 ways you can use this validator:

► By URL - Specify the URL where your XHTML document is located, and click "Check".
► By File Upload - Use the "Browse" to locate an XHTML document on your local hard disk,
and click "Check".
► By Direct Input - Copy & paste the content of an XHTML document to the input area, and
click "Check".

The validator will return a page with validation result.

What Tools to Use to Write XHTML Documents?


The basic tool you need to write XHTML documents is any text editor, like notepad on Windows
system, or vi on Unix system.

If you are looking for some advanced tools to help you writing XHTML documents, you can
select any one from the following three categories of XHTML editors:

► Text based editor - Allows you to work on the text version of the XHTML document.
► WYSIWYG editor - Allows you to work on the rendered version of the XHTML document.
► Browser based editor - A WYSIWYG editor integrated into an existing Web browser.
XHTML editors can also be loaded with additional functionalities to allow you work with other
Web technologies like CSS and JavaScript, or publish the XHTML documents to your Web
server.

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

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.questions-interviews.com/">questions-interviews.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.

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

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.

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.

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>

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="questions-interviews.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="questions-interviews.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.

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 questions-interviews.com/html</h1>

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.

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="questions-interviews.com"/> - Two attributes: ► <img src="ggl.gif"
alt="ggl"/> - Two attributes: "src" and "alt".

HTML DOM Interview Questions and


Answers
This page contains the collection of HTML DOM Interview Questions and Answers / Frequently
Asked Questions (FAQs) under category Web Programming. These questions are collected from
various resources like informative websites, forums, blogs, discussion boards including MSDN
and Wikipedia. These listed questions can surely help in preparing for HTML DOM interview or
job.

What is XML family?


Display : XHTML, XSLT, XSL
Modeling : DTD, XML Schema
Manipulating : DOM, SAX
Querying : Xlink, XQL, Xpath

What is Javascript and how does it work with the DOM?


JavaScript is just one of many programming languages with DOM support. What makes the
combination of JavaScript and the DOM so exciting is the environment where they are used.
Whereas most programming languages do all their work on the server side, putting together pages
to be sent to the browser, JavaScript runs in the browser.

What is HTML DOM?


The HTML DOM is:

* A standard object model for HTML


* A standard programming interface for HTML
* Platform- and language-independent
* A W3C standard

The HTML DOM defines the objects and properties of all HTML elements, and the methods
(interface) to access them.

Explain How DHTML work with JavaScript?


Using JavaScript we can made dynamic HTML content.
We can use document.write() to show dynamic content on your web page.Below I have given you
HTML page which made dynamic after using JavaScript.This example will show current date.
Example:
<html>
<body>
<script type="text/javascript">
document.write(Date());
</script>
</body>
</html>

What is the DOM?


The DOM is a W3C (World Wide Web Consortium) standard.

The DOM defines a standard for accessing documents like HTML and XML:

"The W3C Document Object Model (DOM) is a platform and language-neutral interface that
allows programs and scripts to dynamically access and update the content, structure, and style of
a document."

The DOM is separated into 3 different parts / levels:

* Core DOM - standard model for any structured document


* XML DOM - standard model for XML documents
* HTML DOM - standard model for HTML documents

The DOM defines the objects and properties of all document elements, and the methods
(interface) to access them.

Explain multi-tagging?
Multi-tagging is a technique used by the DOM browser extension to identify a web page UI
object. Whenever possible, DOM extension inserts more than one tag into the object identifier in
following format:
Browser.BrowserChild(page_title).html_class(caption_tag|window_tag)
1. Caption_tag is the caption of the HTML element.
2. #index_tag is the index of this HTML element, counting from the beginning of this page of the
same class of HTML elements.
3. window_tag is the window identifier.

What is difference between DOM and SAX? What would we use if an option is given?
DOM parses an XML document and returns an instance of org.w3c.dom.Document. This
document object's tree must then
be "walked" in order to process the different elements. DOM parses the ENTIRE Document into
memory, and then makes it
available to you. The size of the Document you can parse is limited to the memory available.

Explain DOM and how does it relate to XML?


The Document Object Model (DOM) is an interface
specification maintained by the W3C DOM Workgroup that
defines an application independent mechanism to access,
parse, or update XML data. In simple terms it is a
hierarchical model that allows developers to manipulate XML
documents easily Any developer that has worked extensively
with XML should be able to discuss the concept and use of
DOM objects freely. Additionally, it is not unreasonable to
expect advanced candidates to thoroughly understand its
internal workings and be able to explain how DOM differs
from an event-based interface like SAX.

Explain the syntax of UI object identifier used by DOM extension?


The DOM browser extension uses the following syntax for web UI objects:
Browser.BrowserChild(page_titile).html_class(object_tag)
1. page_title is the title of the web page, defined by the HTML TITLE tag.
2. object_tag is the label of the HTML element. How a HTML element is labeled depending on
the type of HTML element.

Explain How to change HTML Attribute using HTML DOM?


example to change HTML Attribute by using HTML DOM.
Example:
<html>
<body>
<img id="image" src="oldimage.gif">
<script type="text/javascript">
document.getElementById("image").src="newimage.jpg";
</script>
</body>
</html>
In the above example we load an image on HTML document by using id="image".Using DOM
we get the element with id="image".JavaScript that we used in example to changes the src
attribute from oldimage.gif to newimage.jpg
Top

Our Keywords and Ta

You might also like