HTML and CSS Reference
In-Depth Information
The target Attribute and Strict XHTML
The decision not to support the target attribute under strict XHTML was a controversial
one. Many Web page designers prefer to have some links open in new browser windows
or tabs, rather than in the window or tab that displays their site, to allow users to stay at
their site while also browsing on other sites.
One problem is that the ability to open a new window or tab is strictly browser-
dependent. For example, cell phones and PDAs don't support opening new windows,
and those devices are becoming increasingly important tools for viewing the Web.
Another argument is that the action of opening a link in a new window should be left
to each user's preference; it should not be forced on users by Web site designers. Most
browsers provide users the ability to choose where to open links, and that is where the
decision should reside. Finally, there is the opinion that opening new browser windows
for users is actually confusing to new users, who can get lost as the number of open
windows increases with each site they visit.
However, despite these reasons, many Web designers still want to direct links to new
browser windows. One way to allow a link to be opened in a new window but still retain
valid code under XHTML strict is to use JavaScript to open the link. The following code
shows a JavaScript command that can be added to any hypertext link to force the link to
open in a new window:
<aƒhref=” url ”ƒonclick=”;ƒreturnƒfalse;”
ƒƒƒ linkedƒtext
Note that for this approach to work, the user's browser must have JavaScript enabled.
This is the default state for most browsers. However, if JavaScript is not enabled, the
JavaScript code will be ignored and the link will open in the current browser window or tab.
The last two errors in the works.htm file involve using the color attribute and the
<font> tag. The reported errors are as follows:
Line 78, column 25 : there is no attribute “color”
Line 78, column 31 : element “font” undefined
To fix this problem, you'll remove the unsupported color attribute and font element,
replacing them with the following span element and inline style:
You'll make this change now to the works.htm file.
To replace the font element and color attribute:
1. Return to the works.htm file in your text editor.
2. Scroll to the bottom of the file, and then replace
with the following, as shown in Figure 9-24:
Search WWH ::

Custom Search