Skip to main content


An HTML <form> only supports GET and POST methods, whereas Fetch supports GET, POST, PUT, DELETE, HEAD and OPTIONS (source).

Note that if the form is inside a <dialog> we can use method='dialog' (source).


<form action='/search' method='get'>

Form data is added to the URL as query parameters.

  • No request body, and hence no Content-type
  • Idempotent
  • Can be cached
  • Can be bookmarked
  • Length is restricted
  • Not for sensitive data
  • Saved in browser history


<form action='/create-user' method='post'>

Form data is stringified and set as the request body.

  • Content-type: application/x-www-form-urlencoded by default, can be controlled by the attribute enctype
    • Use multipart/form-data if the form contains <input> elements with type=file
  • Request Body: field1=value1&field2=value2
  • Not idempotent, may have side effects
  • Length not restricted
  • For sensitive data
  • Not saved in browser history

Form vs AJAX

When a form is submitted the client navigates to a new URL, sending the data, then it waits for the server response, and finally the browser (client) page refreshes. The request is synchronous and the server dictates how the view updates.

In contrast, when we do an AJAX request, we don’t have to navigate anywhere, and the client does not have to refresh. The request is asynchronous and the client dictates how the view updates.

<selectmenu> (instead of <select>)

Still a draft!

Can be customized, see

<search> (new)


To style the placeholder text of an <input> or <textarea>.

<hr> dividers in <select> elements

:user-valid and :user-invalid instead of :valid and :invalid

A form control that is required and empty will match :invalid even if a user has not started interacting with the page. The same control will not match :user-invalid until the user has changed the input and left it in an invalid state.