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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 110

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.
Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

752 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