What Is This?
The text/css MIME type indicates that the content is a Cascading Style Sheet. When a browser encounters a <link> element or @import rule with text/css, it downloads and applies the stylesheet rules to the HTML document.
Common Uses
Common Use
External stylesheet files linked in HTML documents
Common Use
CSS framework files (Bootstrap, Tailwind)
Common Use
Inline <style> blocks in HTML
Common Use
CSS preprocessor output files
Examples
Serve files with the text/css MIME type:
# Nginx
location ~ \.css$ {
add_header Content-Type "text/css";
}
# Apache
AddType text/css .cssUse this MIME type in HTML or HTTP:
Content-Type: text/css <!-- HTML reference --> <link rel="preload" href="file.css" as="fetch" crossorigin>
Related Entries
More from this reference:
text/html
The MIME type for HTML documents, the standard markup language for web pages.
text/plain
The MIME type for plain text files with no formatting or markup.
text/javascript
The MIME type for JavaScript source files used to add interactivity to web pages.
text/csv
The MIME type for Comma-Separated Values data files.
Frequently Asked Questions
What happens if CSS is served with the wrong MIME type?
Browsers may refuse to apply stylesheets served with incorrect MIME types. If the Content-Type is text/plain or application/octet-stream, the browser blocks the stylesheet for security reasons.
Can I use application/x-css instead of text/css?
No. text/css is the only correct MIME type for CSS. Using application/x-css or other types may cause the browser to reject the stylesheet.