What is the Use of Content Type in HTML?

Learn via video course
FREE
View all courses
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
JavaScript Course With Certification: Unlocking the Power of JavaScript
JavaScript Course With Certification: Unlocking the Power of JavaScript
by Mrinal Bhattacharya
1000
4.8
Start Learning
Topics Covered

The HTML content-type header is an identifier that tells the HTTP client or server the type of media or files the resource is. The content type is also known as the media type or MIME (Multipurpose Internet Mail Extensions) type.

With the help of the specified content type the user agent understands the type of content and improves the user experience by displaying the content accordingly.

Syntax

Transform Your Career

Choose from our industry-leading programs designed for career success

NSDC Certified

Modern Software and AI Engineering Program

Master full-stack development with AI integration

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Modern Data Science and ML with specialisation in AI

Advanced data science techniques with AI specialization

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

Advanced AIML with Specialisation in Agentic AI

Deep dive into AIML with focus on Agentic systems

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

DevOps, Cloud & AI Platform Engineering

Build and manage AI-powered cloud infrastructure

12 MonthsDuration
AI-LedCurriculum
Career SupportSupport
GoogleAmazonPaytm+1000 more
Go to Program
NSDC Certified

AI Engineering Advanced Certification by IIT-Roorkee

Premier AI engineering certification from IIT-Roorkee

3 MonthsDuration
AI-LedCurriculum
Career SupportSupport
Program highlights
Go to Program

Directives

The three directives in the HTML content type are as follows:

  1. media type: The media type directive specifies the MIME (Multipurpose Internet Mail Extensions) type of the resource.
  2. charset: Charset refers to the character encoding standard in which the data will be received by the browsers.
  3. boundary: The boundary directive is used in the case of multipart entities consisting of 1 to 70 characters from a set of characters (without white spaces at the end) known to be very robust through email gateways.

Examples

Free Courses by top Scaler instructors
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course
Python Course for Beginners With Certification: Mastering the Essentials
Java Course - Mastering the Fundamentals
DBMS Course - Master the Fundamentals and Advanced Concepts
JavaScript Course With Certification: Unlocking the Power of JavaScript
C++ Course: Learn the Essentials
Python and SQL for Data Science Course

How the Images are Read by the Browser with and without Setting the Content-type Header

The Content-type header information tells the browser, the type of response it is getting from the server.

How Browser Reads Image With Content-type

How Browser Reads Image Without Content-type

Scaler Placement Report and Statistics

₹23L
AVG CTC
SCALER PLACEMENT PROOF

Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.

11,000+placements
650+companies
Verified data
Hiring Partners:
GoogleGoogleAmazonAmazonMicrosoftMicrosoftFlipkartFlipkartAdobeAdobe1200+ more

Content-Type in HTML Forms

The Content-Type a POST request, received after an HTML form submission, is specified by the enctype attribute on the <form> element. Code

HTML

All Possible Values of HTTP Content-type Header

The commonly used HTTP Content-Type headers are:

Content-TypeValues
Application
  • application/EDI-X12
  • application/EDIFACT
  • application/javascript
  • application/octet-stream
  • application/ogg
  • application/pdf
  • application/xhtml+xml
  • application/msword
  • application/json
  • application/ld+json
  • application/xml
  • application/zip
  • application/x-www-form-urlencoded
Audio
  • audio/mp3
  • audio/mpeg
  • audio/x-ms-wma
  • audio/x-wav
Image
  • image/gif
  • image/jpeg
  • image/png
  • image/tiff
  • image/vnd.microsoft.icon
  • image/x-icon
  • image/vnd.djvu
  • image/svg+xml
Multipart
  • multipart/mixed
  • multipart/alternative
  • multipart/form-data
Text
  • text/css
  • text/csv
  • text/html
  • text/xml
  • text/plain
Video
  • video/mpeg
  • video/mp4
  • video/x-ms-wmv
  • video/x-msvideo
  • video/x-flv
  • video/webm
  • video/quicktime
VND
  • application/vnd.oasis.opendocument.text
  • application/vnd.oasis.opendocument.spreadsheet
  • application/vnd.oasis.opendocument.presentation
  • application/vnd.oasis.opendocument.graphics
  • application/vnd.ms-excel
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • application/vnd.ms-powerpoint
  • application/vnd.openxmlformats-officedocument.presentationml.presentation
  • application/msword
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • application/vnd.mozilla.xul+xml

Turn Learning into Career Growth

1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary
1200+Hiring Partners
89%Placement Rate
11,000+Placements
147%Avg Salary Increment
2.5XCareer Growth
₹23 LPAAvg Post-Scaler Salary

Browser Compatibility

The following browsers support Content-Type::

  • Chrome Edge
  • Firefox Internet
  • Explorer
  • Opera
  • Safari
  • Samsung Internet

Learn more

Conclusion

  • The Content-Type Header is used to represent the original media type of the data for communication between the HTTP client and the server
  • The three directives in the HTML content type are media type, charset, and boundary.
  • By implementing the HTML content type header the user experience is enhanced, leading to the improvement of the site’s performance.