What would be the most appropriate HTML element to encapsulate the word GET on an API instructional page?

StackOverflow https://stackoverflow.com/questions/17838562

  •  04-06-2022
  •  | 
  •  

Question

I'm working on a page with some API instructions. I make efforts to use proper HTML code, whenever possible, but I'm kind of stumped as to what to use for the word GET (as in this is a GET request, not a PUT request) in the instructions. It isn't a big deal, but it does make me feel like I do my job just a bit better.

It's not something that the user types, so <kbd> doesn't really seem relevant. <samp> doesn't seem to fit, either, as it's not something that would be output to the screen. I considered <code>, but that just doesn't sit right.

A lot of the websites that give API instructions don't seem to care much about semantics.

Any recommendations?

Was it helpful?

Solution

From the code element:

The code element represents a fragment of computer code. This could be an XML element name, a filename, a computer program, or any other string that a computer would recognize.

So <code> is the right element to represent an HTTP method (since that is a "string that a computer would recognize). You can even add a class.

<code class="http"><code class="method">GET</code> <code class="Request-URI URI">/</code> <code class="version">HTTP/1.1</code></code>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top