When a browser requests a webpage (HTML or other resources), the server responds with an HTTP status code to tell the browser whether the request was successful, redirected, or failed.


1. What Are HTTP Status Codes?

  • Definition: 3-digit numbers sent by the server in the status line of an HTTP response.
  • Purpose: Indicate the result of the request (success, error, redirect, etc.).
  • Structure: HTTP/1.1 200 OK Content-Type: text/html

2. Categories of HTTP Status Codes

HTTP status codes are divided into 5 classes based on the first digit:

CategoryRangeMeaning
1xx100–199Informational – request received, processing continues
2xx200–299Success – request successfully received and processed
3xx300–399Redirection – further action needed (e.g., new URL)
4xx400–499Client errors – problem with the request
5xx500–599Server errors – problem with the server

3. Common HTTP Status Codes Table

Status CodeNameMeaningHTML Example Scenario
100ContinueInitial part of request OK; continue sendingLarge form upload
200OKRequest successful; HTML content in bodyPage loaded normally
201CreatedNew resource createdHTML form creates an account
204No ContentRequest OK, no body returnedAJAX form submission with no data back
301Moved PermanentlyResource moved; browser should use new URLRedirect from http:// to https://
302Found (Redirect)Temporarily moved to another URLTemporary redirect after login
304Not ModifiedResource not changed; use cached versionBrowser caching HTML/CSS
307Temporary RedirectSame method used; new URL givenTemporary maintenance page
400Bad RequestInvalid request syntaxWrong HTML form data format
401UnauthorizedAuthentication requiredLogin page without credentials
403ForbiddenAccess deniedTrying to open admin page without rights
404Not FoundResource not foundHTML page doesn’t exist
405Method Not AllowedHTTP method not supportedUsing POST instead of GET in HTML form
408Request TimeoutServer timed out waiting for requestSlow HTML form submission
409ConflictRequest conflicts with server stateDuplicate registration in form
410GoneResource removed permanentlyOld HTML page deleted
429Too Many RequestsUser sent too many requestsRefreshing HTML form too fast
500Internal Server ErrorServer crashed or misconfiguredHTML page fails to load due to PHP error
502Bad GatewayInvalid response from upstream serverProxy fetching HTML from backend fails
503Service UnavailableServer overloaded or downMaintenance mode page
504Gateway TimeoutUpstream server didn’t respondSlow backend service for HTML content

4. How They Appear in HTML

Example of a 200 OK response:

HTTP/1.1 200 OK
Content-Type: text/html

<!DOCTYPE html>
<html>
<head><title>Home</title></head>
<body>
  <h1>Welcome!</h1>
</body>
</html>

Example of a 404 Not Found response:

HTTP/1.1 404 Not Found
Content-Type: text/html

<!DOCTYPE html>
<html>
<head><title>Not Found</title></head>
<body>
  <h1>Page Not Found</h1>
</body>
</html>

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *