onClick does not validate under XHTML Strict

Posted on 2008-06-12
Last Modified: 2012-05-05
I am one error away from having my new template validate under XHTML 4.01 Strict. I am getting: Line 122, Column 136: there is no attribute "onClick".

Where I use it is in the code snippet.

How can I get this functionality to validate under XHTML Strict?
<a onclick="window.print()" href="#">Print</a>

Open in new window

Question by:jen4950
LVL 48

Expert Comment

ID: 21773469
do you have onClick or onclick ? and there is no XHTML 4.01 Strict, only HTML 4.01 Strict and there onclick/all attributes are written in lowecase.
LVL 108

Expert Comment

by:Ray Paseur
ID: 21773471
It may not be possible to get it to validate Strict, but this page may lead you to a workaround:

HTH< ~Ray

Author Comment

ID: 21773518
I'm sorry- typo- XHTML 1.0 Strict; I actually used the javascript fix to getaround the _blank target problem; degrades gracefully..

But the onclick problem is a little more elusive.
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

LVL 48

Expert Comment

ID: 21773674
also in XHTML the onclick attribute must be written in lowercase.

Author Comment

ID: 21773806
I've got it in lowercase- here's the file:

Accepted Solution

alexpercsi earned 500 total points
ID: 21781034
You can eliminate it altogether:

Just write
<a href="javascript:void(window.print());">Print</a>

Open in new window


Author Closing Comment

ID: 31466732
Thank you! Well Done!

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now