Jump to content
Sign in to follow this  
vendlus

Xhtml Validation

Recommended Posts

I'm attempting to learn CSS and XHTML by retooling one of my sites. I have it to the point that it is valid with transitional XHTML, but not strict. I have no problem using transitional on my site, but for learning, I'd like to know the differences. :(

 

I'm only getting one error at the moment, but I don't know what to do with it.

 

In my page, I use target="_blank" to have links to other sites open in a new window as opposed to having the person leave my site. Apparantly this is an old attribute and is no longer valid. I'm sure I just don't know where to look yet, but what is the new attribute for what I want to do? (Or what do I put in the css to make it open in a new window.)

Share this post


Link to post
Share on other sites

Ugh... everything I'm looking at sugests using javascript to open new windows. ;) Anyone know of another way or shall I simply be sticking to transitional xhtml for now. :( Since this was my only error with strict, I'm not too worried about it.

Share this post


Link to post
Share on other sites

Unfortunately (or fortunately, depending on your opinion of the matter), the XHTML Strict DTD has removed all references to "target" from any anchor tags. This means that all of the following would be invalid if you coded according to the Strict definition.

<a href="..." target="_blank">

<a href="..." target="_parent">

<a href="..." target="_self">

<a href="..." target="_top">

<a href="..." target="name_of_your_window">

 

Basically, what I'm trying to say is that if it's really important to you to open the link in another window, you'll have to use Javascript to open a new window. You run a slight risk, however, that a user may have javascript disabled on their local machine and will never be able to see the contents of the link.

 

I would do one of two things in this situation (assuming you want and/or need to use the XHTML Strict DTD).

(1) If you need the links to open in a new window, notify the user that they need to make sure Javascript is enabled before clicking the link.

(2) Adhere to the Strict DTD but notify the user that if they wish to return to your web site, they'll need to use their browser's "back" button.

Share this post


Link to post
Share on other sites

Just like Kasey said, XHTML Strict has no 'target' attribute for anchors (links) - my thanks to the kind souls who decided that! :goof: Thumbs Up

 

Can you tell I hate pop up windows? :P

And because of that, I have one more reason to love Mozilla Firefox ;)

 

Anyway, here's some nice reading about that:

http://www.simplebits.com/notebook/2004/05/06/sq.html

 

That site has one of my favorite designs, by the way ;)

Share this post


Link to post
Share on other sites

The main thing is that XHTML 1.1 Strict doesn't support frames. No frames, no targets.

 

I use something like this in my anchors when I'd like to open a new window:

 

><a href="page.html" onClick="window.open('page.html');return false">page.html</a>

 

For those browsers that support javascript (and have it enabled), the onclick will happen - the new window will open, and 'false' will be returned, so that the page doesn't move. If you don't do this, you'll get a new window and you'll get a new page in the existing window.

 

For those browsers who don't support javascript, or don't have it enabled, the onclick event is ignored - so the new page opens in the existing window. While it may mean some people don't get a new window, it will work in many cases - and more importantly, it will degrade gracefully, so if someone doesn't have javascript enabled (or have it at all), they can still get to the link.

Share this post


Link to post
Share on other sites

target="_blank" is bad because....http://diveintoaccessibility.org/day_16_not_opening_new_windows.html

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...