input type="hidden"

An <input type="hidden"> submits a name and value with a form without displaying an editable field to the user.

What you will learn

Basic example

<form action="/cart" method="post">
  <input type="hidden" name="productId" value="42">
  <button type="submit">Add to cart</button>
</form>

When the form is submitted, the browser includes productId=42 in the form data. The field is not rendered like a text box, and it cannot receive focus from the user.

Hidden does not mean secret

Anyone can inspect the page source or developer tools and change the value before submitting the form. Never place passwords, API keys, authorization decisions, or unverified prices in a hidden input. Validate permissions and important values on the server.

Good uses

Related pages