Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 392801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:11:42+00:00 2026-05-12T16:11:42+00:00

I am making a site with DOCTYPE XHTML Strict and it complains if I

  • 0

I am making a site with DOCTYPE XHTML Strict and it complains if I have an input button or button element outside a form.

So I put it in a form and it complains that I don’t have an action attribute.

So I put in an action attribute but then the buttons postback to the page, which I don’t want.

How can I just have a normal jQuery button with bound event in XHTML strict?

<form action="">
    <div>
        <input id="button1" type="button" value="highlight it"  /> 
        <input id="button2" type="button" value="toggle title" />
        <p>here is another paragraph</p>    
    <div id="show1">What color is the sky?</div>
    <div id="answer1">blue</div>
        <button id="button1">Show Answer</button>
    </div>
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T16:11:42+00:00Added an answer on May 12, 2026 at 4:11 pm

    I am making a site with DOCTYPE XHTML Strict and it complains if I have an input button or button element outside a form.

    Nope, it’s perfectly acceptable to have an input/button with no form. Indeed, there is no way in DTD to express the limitation that an input must have a form ancestor, so XHTML couldn’t ban it if it wanted to. If you had a validation error, it wasn’t that. It was probably this:

    <button id="button1">Show Answer</button>
    

    You’ve already got an element with id="button1". ids must be unique.

    When you aren’t going to submit a form, you generally shouldn’t include the form element. However there is one case you need to: to group a set of radio inputs that have the same control name. If they are left with no form ancestor they don’t know they’re connected, so browsers tend not to make them exclusive.

    In this case, the usual idiom is to set the required action attribute to "#", and add an onsubmit handler to the form that always returns false so that when JS is enabled the form will never be submitted. Don’t put this return false on the buttons themselves, as the form may be submitted by other means than a button click: in particular, an Enter keypress.

    So I put in an action attribute but then the buttons postback to the page, which I don’t want.

    An <input type="button"> won’t submit the form. <button> shouldn’t either, but it does in IE due to a bug where the browser uses the wrong default type value. So you have to write <button type="button">.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im making a button that opens a link (web site), but the problem is
I am making a form that submits some values to a site for booking
I am making a site that each account will have an ID. But, I
im making a site that need to have random videos load on the front
I am making a site in django [mysql] that will have to be scalable,
I have a odd problem with Google Maps APIv2 markers. I'm making a site
I am making n alcoholic site that has a gateway for age verification wish
I'm making a web site that users can build their TV watch list. They
I am making a site that depend on users to register to be able
I am making a site that determines the value of an array based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.