logo Learn HTML
  • Home
  • Tutorials
  • Practice
  • Quiz
  • Projects
  • About
  • Contact
animation2.png
animation3.png
animation4.png

HTML Course

  • HTML HOME
  • HTML Introduction
  • HTML Basic
  • HTML Element
  • HTML Attributes
  • HTML Headings
  • HTML Paragrapha
  • HTML Style
  • HTML Formattin
  • HTML Quotations
  • HTML Colors
  • HTML Css
  • HTML Links
  • HTML Image
  • HTML Favicon
  • Page Tittle
  • HTML Tables
  • HTML Lists
  • Block & Inline
  • HTML Div
  • HTML Classes
  • HTML Id
  • HTML Buttons
  • HTML Iframes
  • HTML File Paths
  • HTML Head
  • HTML Layout
  • HTML Symbols
  • HTML Emojis
  • HTML URL Encode
  • HTML VS XHTML
  • HTML FROM
  • HTML Form
  • Form Attributes
  • Form Elements
  • HTML Input Types
  • HTML Input Attributes
  • Input Form Attributes
  • HTML Graphics
  • HTML Canvas
  • HTML SVG
  • HTML Media
  • HTML Media
  • HTML Video
  • HTML Audio
  • HTML Plug-ins
  • HTML Youtube
  • HTML APIS
  • HTML Web APIS
  • HTML Geolocation
  • HTML Drag & Drop
  • Web Storage
  • Web Workers
  • HTML SSE
  • HTML Examples
  • HTML Examples
  • HTML Editor
  • HTML Quiz
  • HTML Exercises
  • HTML References
  • HTML Tag List
  • HTML Attributes
  • HTML Global Attributes
  • HTML Brower Support
  • HTML Events
  • HTML Colors
  • HTML Canvas
  • HTML Audio & Video
  • HTML Doctypes
  • HTML Character Sets
  • HTML URL Encode
  • Language Codes
  • HTTP Messages
  • HTTP Methods
  • PX to EM Converter
  • keyboard Shortcuts

HTTP Request Methods: Talking to the Server

The Hypertext Transfer Protocol (HTTP) is the foundation of data exchange on the web. It functions as a request-response protocol: a client (your browser) sends a request, and a server sends back a response.


1. The Two Most Common Methods

In web development, you will use GET and POST about 90% of the time.


The GET Method

GET is used to retrieve data. Think of it like a search or a page view.

  • Visibility: Data is appended to the URL (e.g., mysite.com/page?id=123).

  • Caching: Browsers can save these requests for faster loading later.

  • Security: Never use GET for passwords because the data is visible in the browser history


The POST Method


POST is used to send data to a server to create or update a resource.

  • Visibility: Data is hidden in the "request body," not shown in the URL.

  • Capacity: There is no limit on how much data you can send (useful for file uploads)

  • Security: Safer than GET for sensitive data, but still requires HTTPS for true security.


2. Comparison: GET vs. POST


Feature GET POST
History Remains in browser history Not saved in history
Bookmarks Can be bookmarked Cannot be bookmarked
Data Length Limited (Max ~2048 chars) No restrictions
Data Type Only ASCII characters No restrictions (Binary allowed)
Visibility Visible in URL Not visible in URL

3. Other Important HTTP Methods

Modern "RESTful" web applications use these specific methods to handle data more efficiently:


  • PUT: Sends data to create or update a resource. It is idempotent, meaning sending the same request 10 times results in the same outcome (it won't create 10 duplicates).

  • PATCH: Used for partial updates. (e.g., changing only a user's email address without sending their whole profile).

  • DELETE: Removes a specific resource from the server.

  • HEAD: Same as GET, but it only asks for the headers (info about the file), not the actual file. Great for checking if a file exists without downloading it.

  • OPTIONS: Asks the server which methods are allowed (useful for security and "CORS" checks).


4. Technical Summary for LearnHTML


Method Idempotent? Cacheable? Purpose
GET Yes Yes Request data
POST No No Create/Submit data
PUT Yes No Replace/Update data
DELETE Yes No Remove data
PATCH No No Modify data partially

Feature GET POST
URL Data Visible Hidden
Security Low (Don't use for passwords) Higher
History Saved Not Saved

Try It Your Self

Sign Up For New
Update

HTML Basic
  1. HTML Basic
  2. HTML Element
  3. HTML Attributes
  4. HTML Headings
  5. HTML Paragrapha
  6. HTML Tables
  7. HTML Lists
HTML Advance
  1. HTML Div
  2. HTML Classes
  3. HTML Id
  4. HTML Buttons
  5. HTML Iframes
  6. HTML Symbols
  7. HTML Emojis