Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some event attributes no longer valid in XHTML

Status
Not open for further replies.

RoseDa

MIS
Joined
Aug 26, 2004
Messages
12
Location
US
I am converting some of my HTML 4 webpages to XHTML.
For some reason XHTML does not allow the body tag to have the OnLoad attribute.

Code:
<body OnLoad="function()">

Also the onclick attribute is not valid for the submit button.

Code:
<input type="submit" name="submitbutton" onclick="validate();return returnVal;" value="Submit" />

Any ideas on valid ways of converting HTML 4 to XHTML?

It still works, but the page will not validate.

Yours,
Dale Rose
 
nonsense.

re: OnLoad,
xhtml is case sensitive; all element attributes must be lower-case.

re: onload and onclick, both are valid event handler attributes per the xhtml reference:

this is perfectly valid xhtml:
Code:
<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Strict//EN"
    "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">[/URL]
<html
  xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL]
  xml:lang="en" lang="en">
  <head>
    <title>test</title>
    <meta
      http-equiv="Content-Type"
      content="text/html; charset=UTF-8" />
  </head>

  <body onload="void(0);">
    <div>
      <form action="#" method="post">
        <div><input
          type="submit"
          onclick="alert('click');" /></div>
      </form>
    </div>
  </body>
</html>

save it locally and run it through the w3c validator:

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top