Topic: "_blank" href target and XHTML Strict

Why does XHTML strict not like "_blank"?

Is there a different way to do the same thing now, or is W3C trying to get people to stop opening links in new windows?

if (!god.exists) life.hopless = true;

Re: "_blank" href target and XHTML Strict

Wayne: Exactly, the W3C realized that it's bad practice. With a regular link, a user has the choice to open it in the same window, a new tab, or a new window. With target="_blank" you are making that choice for them. Think of it like this: You are limiting the options of the user, and when is that ever a good thing? One of the easiest ways to tell whether someone is an amateur is if they still use that type of functionality in their websites. It's just rude to the user, and using JavaScript to get around the doctype is a hacky way of doing it.

Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

But if you desperately need that "_blank", just change the doctype to transitional. But make sure you explicitly point it out to the user that the link is going to "open in a new window" or something. I think informing the user of that is a better way than going "hacky" with JavaScript.

He is no fool who gives what he cannot keep to gain what he cannot lose

Re: "_blank" href target and XHTML Strict

Right, sorry if I sounded harsh, but if it's deprecated in both HTML 4.01 Strict, XHTML 1.0 Strict, and XHTML 1.1 then it must be for good reason. If you must open new windows, make sure you let the user know. Personally, I think the windows opened with target="_blank" usually look cheezy, because it's supposed to be a pop-up, but has the address bar and all the navigation still. Ideally, these types of pop-up windows will be merely informative in nature, with no outgoing links contained within their content. If you're using target="_blank" because you think it will keep people coming back to your site after they close a window, then you are mistaken. That type of thing makes me want to never visit the site again.

Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

Why exactly is this considered bad practice? On all the sites my company builds, all external links open in a new window so that the user does not navigate away from the site (we also do this with pdfs as implentation of downloading them is inconsistent cross-browser).

If the end user clicks a link that leads them off the site, they might not come back to it for one or they might want to go back to the page they were on after awhile only to see it's buried deep in their history. Not good usability.

Nathan, please don't make a global statement off of your personal opinion. We have clients ask for this all the time for the above reason and from their stats, you aren't exactly in the majority. For the record, we rarely use popups and when we do it's with all the navigation junk stripped out.

while ($success == 0) { $try++; }

Re: "_blank" href target and XHTML Strict

dudemagma: No offense, but what the client asks for isn't always in the best interest of the end-user. If all the sites your company builds handle external links like that, maybe you need to reconsider how you build your client's sites. Here's a quote for you:

Andy Clarke wrote:

"People still delivering nested table layout, spacer gifs or ignoring accessibility can no longer call themselves web professionals."

Source - http://accessify.com/2005/11/interview- … ke-aka.php

From what I can tell from your markup, you fit that description pretty accurately. Don't take this the wrong way, but maybe it's time you upgrade your skillset, read a book or something. Here's another good article too: Why Tables for Layout is Stupid (2003).

Again, I mean no disrespect, but I feel that if we keep perpetuating the old paradigm (tables, spacer.gif, pop-ups) then we will never improve and actually make forward progress. I know I didn't exactly candy coat things, but hopefully I am making my point strongly enough to be understood. We started Godbit so that we could raise the bar, not pat people on the back for using antiquated methods.

Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

dudemagma wrote:

Why exactly is this considered bad practice?

Because it is deprecated HTML.  It is outdated technology.  It's the same reason people don't use 28.8kbps modems anymore.

dudemagma wrote:

If the end user clicks a link that leads them off the site, they might not come back to it for one or they might want to go back to the page they were on after awhile only to see it's buried deep in their history. Not good usability.

From a users perspective, bad usability is having 18 browser windows open.  If I'm sifting through the Internet looking for information, I don't care WHOSE site I'm on.  If I click through a site looking for info, and it has a link to somewhere else that has what I'm looking for, I'm not coming back to that site even if it is still open in the background.  Rather, I'm just annoyed that a new window has cluttered my desktop and I have to go to the trouble of closing a window.

Re: "_blank" href target and XHTML Strict

Nathan,

pardon my reaction, but this is the first time i've heard about the target attribute being deprecated, and perhaps i should've read more throughout the forum to get a better idea before commenting...

As for my skillset, i'm always moving it forward, and as I've only been at this about a year and a half it's not quite up to spec in alot of areas (would like to learn javascript, AJAX, and actionscript for example).

If you care to judge for yourself, consider these recent sites that I've done:

http://www.greenacres.com

http://www.lyndonsonline.com

http://www.sleeplevel.net

while ($success == 0) { $try++; }

Re: "_blank" href target and XHTML Strict

dudemagma: No worries man. In retrospect, I was a bit too harsh. Hopefully I didn't put you off to Godbit. Most of the people on this forum are a lot more level-headed than I. Please forgive me if I have made you feel disrespected. I hope you stick around and it will be iron sharpening iron, rather than flame wars. Truce. smile

Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

Matt Heerema wrote:
dudemagma wrote:

Why exactly is this considered bad practice?

Because it is deprecated HTML.

That's circular logic.

It's deprecated, because it's bad practice...

It's bad practice, because it's deprecated...

What would be the best solution to this (yes I read the article that was posted a couple threads down on the whys.)? Is the javascript solution a good compromise?

while ($success == 0) { $try++; }

Re: "_blank" href target and XHTML Strict

I would say the JS solution is a good compromise, as long as it's pulling it's URL from a real <a href> link, instead of writing the link directly to the inline onclick event handler. That way, with JS off, you are still taken to the page. Here's a cool example tool that will build accessible JS popups...

http://accessify.com/tools-and-wizards/ … generator/

Here's an even better one, since it doesn't put the JS in the actual HTML, but calls the popup by classname...

http://mar.anomy.net/files/2004/02/popupdemo/

For an "in-page" popup, check out Cody's ThickBox example...

http://jquery.com/demo/thickbox/

Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

how would you go about that? having the real url hidden in a noscript tag and then having the javascript pull the data from there? I only know a minor about about javascript as a whole.

beat me to it... wink

thanks for the links. smile

Last edited by dudemagma (2006-09-26 19:15:26)

while ($success == 0) { $try++; }

Re: "_blank" href target and XHTML Strict

Nope, just do the actual link, with a class of popup. Look at that middle link above, and you'll see his HTML...

<a href="http://www.example.com" class="popup">Popup link</a>

- with corrosponding JavaScript...

var popupLinkConfig = new Array;

// popupLinkConfig["classname"] = new Array ( "targetname", "width=550,height=350,scrollbars=yes,resizable=yes,status=yes,toolbar=yes,location=yes,menubar=yes");
popupLinkConfig["popup"]    = new Array ( "", "width=350,height=450,scrollbar=yes,menubar=yes");
popupLinkConfig["glossary"] = new Array ( "help", "width=550,height=350,resizable=yes");



// ==========================================================================
window.onload = initPage;  
// Note: Make sure that no other javscripts assign a fuction to window.onload
// There can be only one function tied to window.onload at a time.

function initPage() {
  initPopupLinks();
  // place here any other code you wish to run when the page loads.
}

function initPopupLinks()
{
  if (!document.getElementsByTagName) return true;
  var pageLinks = document.getElementsByTagName("a");
  for (var i = 0; i < pageLinks.length; i++) 
  {
    if (((pageLinks[i].className != null) && 
         (pageLinks[i].className != "")) ||
        ((pageLinks[i].parentNode.className != null) && 
         (pageLinks[i].parentNode.className != "")))
    {
      var linkClass = " " + pageLinks[i].className + " ";
      if ((linkClass == "  ") && (pageLinks[i].parentNode.className != ""))
      {
        linkClass = " " + pageLinks[i].parentNode.className + " ";
      }
      for (var theKey in popupLinkConfig) 
      {
        if (linkClass.indexOf(" " + theKey + " ") > -1)
        {
          if ((pageLinks[i].target == "") || (pageLinks[i].target == null))
          {
            pageLinks[i].target = (popupLinkConfig[theKey][0] != "") ? popupLinkConfig[theKey][0] : theKey;
          }
          pageLinks[i].settings = popupLinkConfig[theKey][1];
          pageLinks[i].onclick = popUp;
        }
      }
    }
  }
  return true;
}

function popUp()
{
  newWin = window.open(this.href, this.target, this.settings);
  newWin.focus();
  return false;
}
Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

Mmmm.... Good lively discussion! I personally never liked the whole target attribute, even though it did have its uses back when i didn't know better. smile A quote from a recent conference I was at:

"To build loyalty and traffic at your site, you need to approach every aspect of your website with its users–not your organization, not your personal preferences–in mind."
-Mike Atkinson

Ninjas and pirates both agree: cowboys suck.

Re: "_blank" href target and XHTML Strict

First, from the user/visitor's perspective, new windows are easy:
If I want to open a link in a new window or tab, I think every modern browser will let me do it.
(Either File>NewWindow or File>NewTab, or even the wonderful right/alt click.)

I'd like to try again about why target="_blank" is bad practice:

A website that is afraid I'll follow a link and not come back is insecure,
like a salesperson behaving desperate and clingy, who doesn't believe in their own product.

They're essentially assuming their own content isn't worth the "back" button,
and it makes me wonder if they're correct.

"I was blind, but now I see!"  John 9:25

Re: "_blank" href target and XHTML Strict

Okay, I'm game. I think some people are missing part of the point because of a few assumptions. I could be wrong, as history has shown...but I'm willing to discuss new ideas, so bring 'em.


ASSUMPTION 1: DESIGNERS USING _BLANK ARE BEING SELFISH
This assumption is, of course, dependent on knowing the motivation of each designer. When I use _blank on CCM Links I'm not doing it to keep people on my site. I'm doing it because I believe it's the most logical way for my site to work. The primary function of the site is to list URLs for Christian musicians. Most people aren't going to come to my website when looking for a specific artist...search engines are likely to take them directly to the artist's site. My site is most often used as a starting point for finding multiple new artists. My stats bear this out, which is why I haven't changed my linking strategy. Most visitors view 8 - 9 pages per visit, and that means that they're jumping out to multiple artist sites. Why would I make it harder for visitors to use my website?

ASSUMPTION 2: _BLANK IS IMPROPER HTML
Of course this isn't correct. It's a valid part of XHTML 1.0 Transitional. I know that that's not the doctype of choice for some people, but it's still 100% valid. _blank may be deprecated in Strict, but it's not deprecated in Transitional. Assuming that _blank is bad because it's not part of XHTML Strict or 1.1 doesn't make sense. Your code should match your doctype...but, as far as I know, XHTML 1.0 Transitional isn't on the chopping block as a deprecated doctype. What's wrong with writing valid and semantic Transitional?

ASSUMPTION 3: USING _BLANK IS ABUSIVE
Come on. Really? I could make the exact same argument for a number of web technologies...like javascript. Back in the day, it was used to make your status bar say something funny. It was used to create bandwidth-stealing effects. It was used to change your cursor into a clock. Does that mean that javascript is bad? Of course not. Embedded Java hijacks my computer. Does that make Java bad? Nope. Most Flashy and AJAXy websites take away my ability to bookmark internal pages. Does that make Flash and AJAX bad? I don't think so. The fact that some have misused _blank has nothing to do with whether it should be used by responsible and thoughtful designers.

ASSUMPTION 4: EVERYONE KNOWS HOW TO OPEN NEW WINDOWS THEMSELVES
You know this isn't true. If memory serves, a Godbit designer with a good reputation didn't know that the middle mouse button opens a new tab in Firefox...and I daresay that most Godbit users are more web-savvy than average. Most people still use IE. There are three ways to open a new window in IE: with the menu, the context menu, and by Shift-clicking. Most of the people I know who are NOT geeks have no idea about any of the three. A friend who's been online for years didn't know that you could right-click on a link until I explained it to him two weeks ago. Even the owner of Priority Training, a group who trains Microsoft employees on the use of Microsoft software, didn't know that Shift-click was an option until I told him. As we all know, web people assume that everyone knows how to use their computer, their browser, their mouse, and and the web. Study after study shows that this is not the case.

ASSUMPTION 5: USING _BLANK MEANS YOU'RE AN UNPROFESSIONAL, AMATEURISH HACK WHO SHOULDN'T BE MAKING WEBSITES
Come on. Really? Nielson says that all hyperlinks should be blue and underlined...does that make everyone here an ignorant swine? Of course not. We all make decisions about how to produce websites, and we all (hopefully) continue learning and changing to improve our decision-making process. I haven't checked in a while, but I'm pretty sure that the code I write for every website would validate as XHTML 1.0 Strict if not for _blank. Does that make my websites 98% good, or 0% good?



note: my host is migrating my sites to a new server today...so you may have trouble accessing CCM Links at times.

We're all looking forward to the future...but none of us more than the giant, evil robots.

Re: "_blank" href target and XHTML Strict

Frankly, I don't think I was making any of those assumptions.

"I was blind, but now I see!"  John 9:25

Re: "_blank" href target and XHTML Strict

Montgomery wrote:

Frankly, I don't think I was making any of those assumptions.

Actually yes...

Montgomery wrote:

First, from the user/visitor's perspective, new windows are easy:
If I want to open a link in a new window or tab, I think every modern browser will let me do it.
(Either File>NewWindow or File>NewTab, or even the wonderful right/alt click.)

Assumption 4

I have to agree with this one on generalhavok's part. I don't think the average user knows how to easily open a link in a new browser (I know my mom doesn't and she uses the net every day).

This also raises the problem of trying to get back to the original site when you encountered a redirect page somewhere in there (you know the ones... where it's almost impossible to get past it using the back button, you have to right click the back button and choose it from your history). The simplest answer to that problem is having the outside page open in a new window.

Montgomery wrote:

A website that is afraid I'll follow a link and not come back is insecure,
like a salesperson behaving desperate and clingy, who doesn't believe in their own product.


They're essentially assuming their own content isn't worth the "back" button,
and it makes me wonder if they're correct.

Assumption 1

Isn't this doing what the quote Larry posted a couple replies up says not to do? Building sites off our preference?

I personally would rather close a couple windows than have to hit the back button numbers of times to (maybe) get back to the page i was on (and find it annoying to have to do so.).

However, since I like to code in 1.0 Strict or 1.1, it seems I need to learn to implement complex javascript options instead of using a simple target attribute.

while ($success == 0) { $try++; }

Re: "_blank" href target and XHTML Strict

Context: I have great respect for the General, and have appreciated his advice several times.

Since I've been described as making these assumptions:

1. "Selfish"? No, I thought we were talking about best practices.
2. "Improper HTML" is a mischaracterization of "bad practice".
3. "Abusive" is a mischaracterization of "bad practice".
4. I'm fully aware that most people don't know how. I said it was "easy", not "common".
5. Hmm. Are we not ever allowed to discuss or recommend best practices?
    (What does a Nielsen recommendation have to do with this discussion?)

I don't understand Dude's point about "Building sites off our preference", since I agree totally with the quote in Larry's comment.
My "preference" is not to limit the user/visitor's choice.

Another assumption I am NOT making:
6. DESIGNERS CAN ALWAYS CHOOSE BEST PRACTICES, EVEN IF A CLIENT INSISTS OTHERWISE.
    (I'd be glad to share a "client insists on disabling right-click" story over a coffee sometime.)

In other words, there's a difference between trying to identify good practice, and excommunicating for any transgression.

Taking a different tack, here are some assumptions I DO make:

Assumption 1: Designers should seek continuing improvement
Assumption 2: Designers can state opinions and recommend best practices
Assumption 3: Designers should consider the user’s/visitor’s/audience’s/community’s experience
Assumption 4: Client’s desires may conflict with that experience.
Assumption 5: No design is perfect.

"I was blind, but now I see!"  John 9:25

Re: "_blank" href target and XHTML Strict

generalhavok wrote:

ASSUMPTION 2: _BLANK IS IMPROPER HTML
Of course this isn't correct. It's a valid part of XHTML 1.0 Transitional. I know that that's not the doctype of choice for some people, but it's still 100% valid. _blank may be deprecated in Strict, but it's not deprecated in Transitional. Assuming that _blank is bad because it's not part of XHTML Strict or 1.1 doesn't make sense. Your code should match your doctype...but, as far as I know, XHTML 1.0 Transitional isn't on the chopping block as a deprecated doctype. What's wrong with writing valid and semantic Transitional?

I agree with you that it's perfectly valid for XHTML 1.0 Transitional. And that's what the Transitional DOCTYPE is for... to be, you know, a transition. One of the problems I see, however, is that HTML first came out in 2000... and now it's 2006. Shouldn't we be coding our sites in Strict by now? Heck, the seventh public Working Draft of XHTML 2.0 was published last year.

The target attribute was designed for framesets — if you want to use targets, use an XHTML Frameset or XHTML Transitional DOCTYPE. Given this, it's just really bad practice to use the target attribute for something it wasn't designed for. You know, kinda like using tables for the layout of a site, which I think we all can agree is bad.

Ninjas and pirates both agree: cowboys suck.

Re: "_blank" href target and XHTML Strict

I just wanted to note here that opening links in a new window, in principle, is not deprecated by the W3C, neither is it old technology. The reason the target="" attribute was removed was because it is apparently presentation rather than content and was supposed to be replaced in CSS3, which hasn't been released yet.

Jonathon VS - Code Prodigy, Token Canadian at Synergema - Personal Website

Re: "_blank" href target and XHTML Strict

Jonathon VS wrote:

The reason the target="" attribute was removed was because it is apparently presentation rather than content and was supposed to be replaced in CSS3, which hasn't been released yet.

I would agree, except I would say that this falls under the area of behavior. Whether or not a new window is opened is not a presentational issue. I mean, we're not re-styling anything with target="", we're causing the typical behavior of leaving the page for a new one to be altered. So, in reality it has nothing at all to do with any version of CSS, and everything to do with JavaScript, which handles the behavioral layer.

Give me liturgy or give me death.

Re: "_blank" href target and XHTML Strict

Larry Tomlinson wrote:

I agree with you that it's perfectly valid for XHTML 1.0 Transitional. And that's what the Transitional DOCTYPE is for... to be, you know, a transition. One of the problems I see, however, is that HTML first came out in 2000... and now it's 2006. Shouldn't we be coding our sites in Strict by now? Heck, the seventh public Working Draft of XHTML 2.0 was published last year.

That's something that bothers me. I've never understood why anyone would create a Transitional spec. Seems weird. The real question is "when will the W3C phase out the transitional DTD? If it's really transitional with regard to time, it shouldn't last forever...right?

As I've said before: my sites probably validate as strict without _blank...but I can't give it up yet. If someone can convince me, I will...but so far I'm not convinced.

...it's just really bad practice to use the target attribute for something it wasn't designed for. You know, kinda like using tables for the layout of a site, which I think we all can agree is bad.

I think there's a difference. The fact that target works for frames and for regular pages doesn't mean the tag is being misused...it's still a semantic expression. Now, using <b> as a block level element that contains your entire navigation system isn't semantic, but target seems semantic to me. It can't be used in any other way, so how is it being misused? I'm curious.

Nathan:
I realize that I'm a bit of a throwback, but I try to avoid using javascript unless it's necessary. Since Transitional is a valid DTD, and _blank isn't deprecated for Transitional, and since it works in all browsers (where javascript doesn't) and its reach is virtually 100%, why would I choose a javascript solution over an (x)html one? Help me out here. I'm not advocating _blank, I'm using it because I haven't seen a better way to accomplish my goals. smile

We're all looking forward to the future...but none of us more than the giant, evil robots.

Re: "_blank" href target and XHTML Strict

generalhavok wrote:

I think there's a difference. The fact that target works for frames and for regular pages doesn't mean the tag is being misused...it's still a semantic expression. Now, using <b> as a block level element that contains your entire navigation system isn't semantic, but target seems semantic to me. It can't be used in any other way, so how is it being misused? I'm curious.

Well played sir. Now that I think about it, using _blank is actually calling a new frame to load the page in. But, if you wanted to use frames, you'd use the XHTML Frameset doctype, which eventually will be replaced by XFrames. wink

Ninjas and pirates both agree: cowboys suck.

Re: "_blank" href target and XHTML Strict

Frames? I'd sooner use AOL...and that isn't going to happen.

We're all looking forward to the future...but none of us more than the giant, evil robots.