HTML and CSS Reference
In-Depth Information
browser looks them up in the namespace to find out how they should be
used.
For instance, the <a> tag's name ( a ) and attributes (e.g., href and style )
are defined in the XHTML DTD, and their names are placed in the DTD's
namespace. Any processing agentusually a browser, but your eyes and
brain can serve the same functioncan look up the name in the appropri-
ate DTD to figure out what the markup means and what it should do.
With XML, your document actually can use more than one DTD and
therefore require more than one namespace. For example, you might
create a transitional XHTML document but also include special markup
for some math expressions according to an XML math language. What
happens when both the XHTML DTD and the math DTD use the same
name to define different elements, such as <a> for XHTML hypertext and
<a> for an absolute value in math? How does the browser choose which
namespace to use?
The answer is the xmlns [*] attribute. Use it to define one or more al-
ternative namespaces within your document. You can place it within the
start tag of any element within your document, and its URL-like [ ] value
defines the namespace that the browser should use for all content with-
in that element.
[*] XML namespace xmlns get it? This is why XML doesn't let you begin any element or attribute with
the three-letter prefix of "xml": it's reserved for special XML attributes and elements.
[ ] It looks like a URL, and you might think that it references a document that contains the namespace,
but alas, it doesn't. It is simply a unique name that identifies the namespace. Display agents use that
placeholder to refer to their own resources for how to treat the named element or attribute.
With XHTML, according to XML conventions, you should at the very least
include within your document's <html> tag an xmlns attribute that identi-
fies the primary namespace used throughout the document:
<html xmlns="http://www.w3.org/TR/xhtml1">
 
 
Search WWH ::




Custom Search