Web Analytics

HTML Form Attributes

Intermediate ~10 min read

The Action Attribute

The action attribute specifies where to send the form data when submitted. It usually points to a server-side script.

HTML
CSS
JS

The Method Attribute

The method attribute specifies how to send form data:

  • GET - Appends data to URL (visible, bookmarkable, limited size)
  • POST - Sends data in request body (hidden, no size limit)
HTML
CSS
JS
Best Practice: Use GET for searches and filters. Use POST for sensitive data like passwords or when modifying data.

The Enctype Attribute

The enctype specifies how form data should be encoded. It's required for file uploads:

  • application/x-www-form-urlencoded - Default, encodes all characters
  • multipart/form-data - Required for file uploads
  • text/plain - Sends data without encoding (not recommended)
HTML
CSS
JS

Other Form Attributes

  • target - Where to display response (_self, _blank, _parent, _top)
  • autocomplete - Enable/disable browser autocomplete (on/off)
  • novalidate - Disable browser validation
  • name - Name for the form (used in JavaScript)

Quick Quiz

Which enctype is required for file uploads?

A
application/x-www-form-urlencoded
B
multipart/form-data
C
text/plain
D
application/json