Skip to main content

HTML Guide

The element “input” must not appear as a descendant of the “button” element.

An input element cannot be placed inside a button element because the HTML standard prohibits interactive content as descendants of a button.

According to the HTML specification, interactive content (like input, button, select, etc.) must not be nested inside button elements. This restriction exists to prevent invalid or unpredictable behavior in user interfaces. For accessible and valid markup, each form control should be a separate, direct child of its container, not nested inside another interactive element.

Example of invalid HTML

<button>
  Submit
  <input type="text" name="example">
</button>

Correct HTML structure

<form>
  <input type="text" name="example">
  <button type="submit">Submit</button>
</form>

Always ensure that form elements such as input and button are not nested within each other. Keep them as siblings within a form or appropriate container.

Learn more:

Related W3C validator issues