Search code examples
htmlbuttonheaderaccessibilitymarkup

Is button in header valid ? <h1><button> Caption </button></h1>


Is this possible or is it not valid?

<h1>
  <button>
     Caption
  </button>
</h1>

This header is the heading of an accordion. Therefore its a button as it opens and closes the accordion but semantically its a header as its the important chapters of the page. What do you suggest?


Solution

  • First of all, try the W3C Validator instead of opening a new question every time you want to know if your HTML is valid.

    Now to your question - yes it is valid.