Shaun Mccran

My digital playground

22
J
A
N
2010

Strict or Transitional DTD type validation, worth hacking just to pass?

An area of web development that I previously had little exposure to was WCAG validation. This is the industry standard for Accessibility coding for web platforms. For version two (V2) of the WCAG there are three standards, A, AA and triple A (AAA). Each represents different levels of Accessible compatibility.

What this also does is validate against the W3C doctype standards. This is where my problems arose. The main aim of the doctype standard is to clearly define a separation layer between content and behaviour. In practical terms this equates to best practices such as having an external .CSS files rather than inline styling, and declaring the language types for scripting, such as JavaScript etc.

Using a free online tool, http://www.totalvalidator.com/ you can check if your site is W3C and WCAG complaint. It will base the validation on the doctype declared in your html. There are three types of DTD declaration for html 4.01.

view plain print about
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
3<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
4
5<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/frameset.dtd">

You can read more about Doctypes here: http://www.w3schools.com/tags/tag_DOCTYPE.asp

The main difference between these is that the frameset DTD will accept frameset as valid html, whereas the others will not. Also the Strict DTD imposes a very tight restriction of what is accepted as valid in comparison to the Transitional DTD. One is a Strict adherance to the standard, whereas the other shows that you are Transitioning from old code into the new.

The site http://24ways.org/2005/transitional-vs-strict-markup goes into more detail about what the exact differences are, what I am going to discuss is the option of creating functional hacks, merely to pass validation.

One of the deprecated attributes in Strict validation is the target attribute.

view plain print about
1<a href=http://www.mywebsite.com target=_blank>Follow this link to go to my website</a>

We are all familiar with this attribute, but when you examine it you find that it is actually a declaration of behaviour. We are forcing the user into a specific action. IE open a new window. As a best practice guideline whenever we have a link on a site that exits that site, we open a new window. The only work around for this is creating a specific JavaScript function to open a new window, as this will not be marked as invalid. This seems overkill, just to pass validation.

So I am left with the dilemma that if I want my sites to pass Strict DTD validation I must create a JavaScript hack, or compromise the functionality. I'd like to pass the validation, but I view the functionality as key to a site, so it's an easy decision for me.

TweetBacks
Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
darren james's Gravatar Hi Shaun,

great blog! interesting dilemma, some would argue that you should never force that behaviour (i.e. openning a link in a new window) on a visitor and they should decide themselves whether to open a new window r not.

In accessibility terms you could also argue that openning multiple windows causes accessibility "issues" (i.e. multiple open windows), especially if you open them without informing the user.

Keep up the good work!
# Posted By darren james | 22/01/2010 13:25
Josh Knutson's Gravatar I know that for the last year or so I have been using onclick="target='_blank';" but a few moths back I switched it so there is a class of _blank on the link that I can look for. It may seem a bit hacky but its also kind of nice in case we want all those links to open up modal windows or something it will be easier to switch them.
# Posted By Josh Knutson | 25/01/2010 00:05
Julian Halliwell's Gravatar Shaun, I'd agree with Darren that it's not good practice to force links to open in new windows. Another important reason is that it breaks the Back button. The newly opened window does not inherit the page history of the parent window, so the new window's Back button won't work. Many users won't be aware that they've been transferred to a new window and will wonder why they can't click "Back" to return to your site.

Clients tend to think opening external links in new windows makes it easier to return to their own site, but in fact the oppposite is often the case.
# Posted By Julian Halliwell | 25/01/2010 08:15
Shaun McCran's Gravatar Darren, Julian you raise good points on forcing a specific behaviour on a user. I guess it just seems a shame to push users away from your site after all the trouble of trying to get them there in the first place! Maybe I'll re-examine my best practices doc.

Josh, you mentioned that you use a class definition of "_blank", do you just pick this up in JQuery then as a new window identifier?
# Posted By Shaun McCran | 25/01/2010 09:17
Julian Halliwell's Gravatar Yep, that's what clients usually think. But the web is a network of links that people are free to navigate as they please. Trying to "trap" them is counter-productive. Instead, just make it easy to get back to your site by making sure the Back button works the way people expect.
# Posted By Julian Halliwell | 25/01/2010 09:30
Back to top