Interview Question

What is the method attribute in forms?

Method chooses how a form submits its data.

💡 Concept ✅ Quick Revision 🌐 HTML

Answer

The `method` attribute selects the HTTP method used for form submission, commonly `get` or `post`. β€’ It is written inside an element’s opening tag. β€’ The HTML Standard limits which elements may use it and which values are valid. β€’ Browsers apply the attribute when they process the element or the resource it controls.

💡 Simple Example

<form action="/search" method="get"><label for="query">Search</label><input id="query" name="q"><button type="submit">Search</button></form>

⚡ Quick Revision

Method chooses how a form submits its data.