14

I have seen HTTP methods written in all caps and in all lowercase letters. Is there any reason why you would want to write POST rather than post in the method attribute of a form element, for example?

Do some browsers handle capitalized POST and GET differently than lowercase post and get?

TrentonMcManus
  • 487
  • 1
  • 7
  • 16
  • It's, actually, doesn't matter `POST` and `post` will be interpreted as the same. This question, seems to be, the duplicate of [this one](https://stackoverflow.com/questions/4106544/post-vs-post-get-vs-get) –  Nov 21 '17 at 04:35

3 Answers3

8

The HTML5 spec requires to use "get" or "post".

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
  • 4
    XHTML required the method attribute of a `
    ` to be either `"get"` or `"post"`, in lowercase. This seems perverse, since HTTP requires that the method be sent in uppercase, but I just checked using the W3 validator and it is so. This is presumably where the practice of referring to HTTP methods in lowercase comes from.
    – Mark Amery Feb 02 '14 at 10:53
  • 1
    "I'm sure it's described somewhere in the HTML5 spec" - yes it is of course! And the HTML 5 standard allows only lowercase. Why don't you take the 2 minutes to look it up before writing an answer? – Christopher K. Aug 23 '17 at 08:53
  • The HTML5 spec mentions: "The `method` and `formmethod` content attributes are enumerated attributes"..." and that an enumerated attribute's value "must be an ASCII case-insensitive match for one of the given keywords", meaning "the characters in the range U+0041 to U+005A (i.e., LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and the corresponding characters in the range U+0061 to U+007A (i.e., LATIN SMALL LETTER A to LATIN SMALL LETTER Z) are considered to also match". So you can write `POST`, `post`, `PoSt`, `poST` etc. They're all valid. Just pick one style, and use it consistently. – Alex Jun 26 '20 at 22:37
7

Short answer: Best use lowercase in method attributes of <form> tags.

Long answer: It slightly depends on the HTML version:

HTML5: The html5 living standard states that lowercase get maps to the HTTP method GET and that lowercase post maps to HTTP method POST [1]. However as of today, enumerated attributes match case-insensitive [2]. So you could in theory use any casing. I am pretty sure this was different a couple of years a ago, but that's the nature of a living standard. The examples in the HTML5 standard use lowercase. So, if you follow HTML5 standard, I would recommend to use lowercase, even though it does not really matter.

XHTML: Use lowercase. The DTD of xhtml-strict and xhtml-transitional only define lowercase get and post [3, 4]. Here its is even more important, as using uppercase will produce an invalid XHTML document that can trigger ugly browser errors in practice (depends on DTD, browser and http content-type).

HTML 4: In these days, it was common practice to use uppercase, but lowercase also worked well in practice. This is just my personal experience, I am not going to look up the HTML 4 standard as it seems irrelevant nowadays (and nobody ever followed it strictly anyways).

[1] https://www.w3.org/TR/html5/forms.html#attr-fs-method

[2] https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute

[3] https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd line 695

[4] https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd line 888

Christopher K.
  • 1,015
  • 12
  • 18
1

Your site will work fine whether you use POST or post in your form's method declaration. It has more to do with the doctype you choose. If you use XHTML, everything must be lowercase. If you do not (and use HTML5 for example) it does not matter and can even be PoSt if you like. I personally still would go for the lowercase variant but the choise is yours. Whatever you choose, the important thing is...stick with it in the rest of your page.

Bas Slagter
  • 9,831
  • 7
  • 47
  • 78
  • You are mistaken on all counts.The HTTP method is case-sensitive, and this has nothing to do with the DOCTYPE of the content. – user207421 Oct 17 '11 at 07:34
  • 1
    @ejp: that's weird. I always use it lowercase and it works just fine. And as far as I know, a validator will complain about the method="POST" if your doctype is xhtml. – Bas Slagter Oct 17 '11 at 07:40
  • XHTML is not HTTP. The XHTML validator can't even see the HTTP method. It can see the document, and the word POST inside the document, if it occurs there for some other reason. These are not the same thing. – user207421 Oct 17 '11 at 07:45
  • 1
    @ejp: but the poster is specifically asking about the "method attribute of a form element"... – Bas Slagter Oct 17 '11 at 07:49