of the XHTML 1.1 Target Module.
When deciding what XHTML specification to development in, XHTML Loose is a tempting choice because it's pretty much exactly like HTML 4.0. XHTML Transitional is a close second, because not much more laziness need be given up to perform to that standard. However with XHTML Strict, a few more tags have to be modified in order to successfully make the transition. The most annoying one to my mind has been the loss of the anchor element's target attribute. However, a little more effort can bring you to the most current of the XHTML standards, XHTML 1.1, as well as return the lamented target functionally.
HTML 4.01 deprecated the target attribute which could be used with links so they would open in a new window. Consequentially this attribute was deprecated in the XHTML 1.0 standard. The deprecation of this attribute did not change the web designer's desire to open certain links is a new browser window. The following is an example of an HTML 4.01 transitional HTML document using the target attribute.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Example of a Target Attribute</title>
</head>
<body>
<p>
<a href="http://www.TexaStar.com"
target="_blank">TexaStar</a>
</p>
</body>
</html>
Javascript provides a partial solution to the problem by passing the href attribute to the window object's open method, and returning a value of false. The false return from the event handler prevents the web browser from following the link specified in the href attribute.
<a href="http://www.TexaStar.com"
onclick="window.open(this.href); return false;"
onkeypress="window.open(this.href); return false;">TexaStar</a>
This previous example provides an onclick event handler for those using a pointing device, and an onkeypress event handler for those using a keyboard. However, when JavaScript isn't enabled, the link is processed as normal, providing a possibly adequate fallback mechanism, but failing to produce the designer's desired result.
XHTML 1.1 Modularization [ XHTMLMOD] breaks down XHTML 1.0 Strict and by reference HTML 4, into a collection of abstract modules that provide specific types of functionality. Instead of having one huge DTD that defines everything; modules are used as needed and supported by device. To ensure the basis of XHTML is consistent, four core modules are specified.
| Module Name | Module Description | DTD Fragment |
|---|---|---|
| Hypertext | Hypertext Module Definition. | Hypertext Module Implementation. |
| List | List Module Definition. | List Module Implementation. |
| Modular Framework Module | Modular Framework Module Definition. | Modular Framework Module Implementation. |
| Text | Text Module Definition. | Text Module Implementation. |
In addition to the four core modules, a number of additional abstract modules are defined.
As noted in the above table, some of the modules are not included by default in the XHTML 1.1 DTD. These modules may be used to extend the basic DTD to incorporate desired functionality. Below is a sample DTD which can be hosted on your site, or reference from our site, to bring in the target module and allow the specification of a target attribute in the anchor element.
<?xml
version="1.0"
encoding="iso-8859-1"?>
<!--
XHTML 1.1-with Target
-->
<!--
ENTITIES XHTML
data types module for basic data types
-->
<!ENTITY % xhtml-datatypes.module "INCLUDE">
<![%xhtml-datatypes.module;[
<!ENTITY % xhtml-datatypes.mod
PUBLIC "-//W3C//ENTITIES XHTML Datatypes 1.0//EN"
"http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-datatypes-1.mod">
%xhtml-datatypes.mod;]]>
<!--
ENTITIES Qualified Name
namespace declarations and parameter entities
-->
<!ENTITY % xhtml-qname.module "INCLUDE">
<![%xhtml-qname.module;[
<!ENTITY % xhtml-qname.mod
PUBLIC "-//W3C//ENTITIES XHTML Qualified Names 1.0//EN"
"http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-qname-1.mod">
%xhtml-qname.mod;]]>
<!--
XHTML 1.1 driver DTD
-->
<!ENTITY % xhtml11.dtd
PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
%xhtml11.dtd;
<!--
Target Module
-->
<!ENTITY % xhtml-target.module "INCLUDE">
<![%xhtml-target.module;[
<!ENTITY % xhtml-target.mod
PUBLIC "-//W3C//ELEMENTS XHTML Target Module//EN"
"http://www.w3.org/TR/xhtml-modularization/DTD/xhtml-target-1.mod">
%xhtml-target.mod;]]>
The final step of this process is to create a web page utilizing this functionally, and accessing the modular DTD with the following DOCTYPE.
<!DOCTYPE html
PUBLIC "-//TexaStar//DTD XHTML11-with Target//EN"
"http://www.TexaStar.com/DTD/xhtml11-target.dtd">
This page, and others on this site are implemented using the demonstration DTD and you may view more details by viewing the of this document you are viewing. Furthermore, use the links at the bottom of this page to validate it against the CSS, XML and 508/AAA specifications.The Test Target Link from the top of the page, is shown here for reference.
<a
href="http://www.texastar.com"
class="emphasis"
target="_blank"
onclick="window.open(this.href); return false;"
onkeypress="window.open(this.href); return false;">Test
Target Link</a>
Given that the XHTML 1.1 Modularization use of the Target Module provides full target functionally, it begs the question of whether or not one should continue to use the onclick and onkeypress JavaScript methods previously mentioned. As alwasy it is a choice based on the preferences of the designer, skill of the developer, financial backing of both, and the target audience.
Old browser agents do not support XHTML. JavaScript may be unsupported or disabled. JavaScript was only first introduced in the Netscape Browser version 2.0 in December 1995. The simplest fallback being completely to ignore the target attribute and linking to the page in the current browswer window contrary to the designer's intent.
Therefore, the most robust implementations to reach the broadest audience with the design intent would reqire the implementation of the XHTML 1.1 Target Module, as well as inclusion of both the onclick and onkeypress event handlers as displayed above.
Sign up for a web site with TexaStar Hosting
Written by: Erik McCarty <erik@texastar.com>This page is designed for all browsers and devices and is authored to W3C recommendations including XHTML 1.0 Transitional and Cascading Style Sheets. It is Bobby Approved to the WAI Content Accessibility Guidelines 1999/05/05, Support Level: AAA and complies with the U.S. Section 508 Guidelines: Electronic and Information Technology Accessibility Standards. As a result, this web page displays as intended in Opera 5, Opera 6, MSIE5, MSIE4 MacIntosh Edition , MSIE5.5, MSIE6, Netscape 6, and title="External Link: Mozilla" Mozilla (possibly the best browser ever), while its text is available to any browser or Internet device, from Netscape 1.0 to Palm Pilots and web phones, and in those displays is intended to degrade to a readable and logically organized layout.