text/css MIME Type — CSS Content-Type & MIME Sniffing Prevention
Cascading Style Sheets. The styling language for HTML documents. Browsers block page rendering until CSS is loaded, making correct Content-Type critical — browsers refuse to apply stylesheets served with the wrong MIME type (MIME sniffing is blocked by X-Content-Type-Options: nosniff).
Used For
- Web page stylesheets
- CSS custom property themes
- Email style blocks (limited support)
HTTP Header Example
HTTP/1.1 200 OK
Content-Type: text/css; charset=utf-8
Cache-Control: public, max-age=31536000
X-Content-Type-Options: nosniffCode Examples
// Express — serve CSS from public directory
import express from 'express'
app.use(express.static('public')) // serves .css with text/css automatically
// nginx — correct MIME type (types block)
# nginx.conf
types {
text/css css;
}
// Inline CSS via <style> tag (no MIME type needed)
// <link rel="stylesheet" href="/style.css" type="text/css">Related MIME Types
Frequently Asked Questions
What is the text/css MIME type?
Cascading Style Sheets. The styling language for HTML documents. Browsers block page rendering until CSS is loaded, making correct Content-Type critical — browsers refuse to apply stylesheets served with the wrong MIME type (MIME sniffing is blocked by X-Content-Type-Options: nosniff).
When should I set Content-Type: text/css?
Set Content-Type: text/css on HTTP responses that contain CSS data. Web page stylesheets.
What file extensions use text/css?
Files with text/css content typically use these extensions: .css.
What happens if I serve this with the wrong Content-Type?
Browsers use the Content-Type header to decide how to handle the response. Serving text/css content with an incorrect MIME type can cause browsers to display it incorrectly, refuse to execute it (scripts), or prompt an unintended download. Modern browsers respect X-Content-Type-Options: nosniff and will not attempt to auto-detect the type.
