- HTTP Media Types
- Example
- Using media types
- Commonly used media types
- Application
- Audio
- Font
- Image
- Message
- Model
- Multipart
- Text
- Video
- Default media types
- You may also like
- CSS Media Queries
- CSS3 Introduced Media Queries
- Browser Support
- Media Query Syntax
- CSS3 Media Types
- Media Queries Simple Examples
- Example
- Example
- More Media Query Examples
- CSS @media Reference
HTTP Media Types
HTTP Media Types is a standard that specifies the nature and format of a file. Browsers rely on media types, rather than file extensions, to know how to handle a file. Media types are formerly known as MIME types.
Example
Two elements with type attributes which specify the media types .
Media types for the video files are: video/mp4 and video/ogg .
Using media types
A media type indicates the format and nature of a document. Browsers don’t look at a link’s file extension, but rather what media type it is. The IANA organization maintains a list of all official media types. Below are lists of commonly used media types.
Commonly used media types
Type | Description |
---|---|
application | Binary data that require an application |
audio | Audio and music files |
font | Font and typeface files |
image | Graphical data formats |
message | Email and messaging formats |
model | Model data to create 2d or 3d scenes |
multipart | Data with multiple media types |
text | Readable text files |
video | Video and movie files |
Application
Media type | Description |
---|---|
application/atom+xml | Atom feed format |
application/octet-stream | Any kind of binary file |
application/vnd.amazon.ebook | Amazon Kindle book format |
application/octet-stream | Any type of binary file |
application/epub+zip | Epub book format |
application/zip | Zip archive format |
application/pdf | Pdf file format |
application/json | Json format |
application/java-archive | Jar format |
application/msword | Microsoft Word |
application/vnd.openxmlformats-officedocument.wordprocessingml.document | Microsoft Word (OpenXML) |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
application/pdf | Pdf file format |
Audio
Media type | Description |
---|---|
audio/mpeg | Mp3 audio format |
audio/ogg | Ogg audio format |
audio/wav | Waveform audio format |
Font
Media type | Description |
---|---|
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
font/pdf | Font |
Image
Media type | Description |
---|---|
image/jpeg | Jpeg image |
image/png | Portable Network Graphics image |
image/avif | Aliance for Open Media image |
image/webp | Webp image |
image/svg+xml | Scalable Vector Graphics (SVG) |
image/tiff | Tagged Image File Format (TIFF) |
image/gif | Graphics Interchange Format (GIF) |
image/bmp | Windows OS/2 Bitmap Graphics |
Message
Media type | Description |
---|---|
message/http | Http message |
message/partial | Email message |
message/rfc822 | Email subtype with encapsulated message |
message/imdn+xml: | Imdn message |
message/pdf | Message |
message/pdf | Message |
message/pdf | Message |
message/pdf | Message |
message/pdf | Message |
message/pdf | Message |
Model
Media type | Description |
---|---|
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
model/pdf | Model |
Multipart
Media type | Description |
---|---|
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
multipart/pdf | Multipart |
Text
Media type | Description |
---|---|
text/plain | Plain text: ASCII or ISO 8859 |
text/html | HTML format |
text/css | CSS format |
text/javascript | JavaScript |
text/csv | Comma separated values (CSV) |
text/pdf | Text |
text/pdf | Text |
text/pdf | Text |
text/pdf | Text |
text/pdf | Text |
text/pdf | Text |
text/pdf | Text |
Video
Media type | Description |
---|---|
video/mp4 | Mp4 format |
video/mpeg | Mp3 or other Mpeg format |
video/ogg | A variety of formats inside an Ogg container |
Default media types
- text/plain — for text files (i.e. human readable files), or
- application/octet-stream — for binary files and files of unknown type
You may also like
Sign up and we’ll send you the best freelance opportunities straight to your inbox.
We’re building the largest self-service freelancing marketplace for people like you.
CSS Media Queries
The @media rule, introduced in CSS2, made it possible to define different style rules for different media types.
Examples: You could have one set of style rules for computer screens, one for printers, one for handheld devices, one for television-type devices, and so on.
Unfortunately these media types never got a lot of support by devices, other than the print media type.
CSS3 Introduced Media Queries
Media queries in CSS3 extended the CSS2 media types idea: Instead of looking for a type of device, they look at the capability of the device.
Media queries can be used to check many things, such as:
- width and height of the viewport
- width and height of the device
- orientation (is the tablet/phone in landscape or portrait mode?)
- resolution
Using media queries are a popular technique for delivering a tailored style sheet to desktops, laptops, tablets, and mobile phones (such as iPhone and Android phones).
Browser Support
The numbers in the table specifies the first browser version that fully supports the @media rule.
Media Query Syntax
A media query consists of a media type and can contain one or more expressions, which resolve to either true or false.
The result of the query is true if the specified media type matches the type of device the document is being displayed on and all expressions in the media query are true. When a media query is true, the corresponding style sheet or style rules are applied, following the normal cascading rules.
Unless you use the not or only operators, the media type is optional and the all type will be implied.
You can also have different stylesheets for different media:
CSS3 Media Types
Value | Description |
---|---|
all | Used for all media type devices |
Used for printers | |
screen | Used for computer screens, tablets, smart-phones etc. |
speech | Used for screenreaders that «reads» the page out loud |
Media Queries Simple Examples
One way to use media queries is to have an alternate CSS section right inside your style sheet.
The following example changes the background-color to lightgreen if the viewport is 480 pixels wide or wider (if the viewport is less than 480 pixels, the background-color will be pink):
Example
The following example shows a menu that will float to the left of the page if the viewport is 480 pixels wide or wider (if the viewport is less than 480 pixels, the menu will be on top of the content):
Example
More Media Query Examples
For much more examples on media queries, go to the next page: CSS MQ Examples.
CSS @media Reference
For a full overview of all the media types and features/expressions, please look at the @media rule in our CSS reference.