devkult_
tools29converters34
home/mime/.css

.css MIME type

CSS stylesheettext & code

text/css

Stylesheets. Browsers refuse to apply a stylesheet served with any other type in standards mode.

MIME typetext/css
Extensions.css
Content-Typetext/css; charset=utf-8
Compress in transit?Yes — enable gzip or Brotli

Good to know

  • A wrong type shows up in the console as "Refused to apply style… because its MIME type ('text/plain') is not a supported stylesheet MIME type".
  • With X-Content-Type-Options: nosniff, browsers enforce the type strictly.

Serve .css files with the right type

The response header to send:

Content-Type: text/css; charset=utf-8

Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:

nginx (inside the types block in mime.types)
text/css css;
Apache (.htaccess or server config)
AddType text/css .css
Express
res.set("Content-Type", "text/css; charset=utf-8");
Python
import mimetypes

mimetypes.add_type("text/css", ".css")
HTML file input
<input type="file" accept=".css,text/css">

Check it

See what a server sends for a file, and what type a local file really is by its contents:

curl -sI https://example.com/file.css | grep -i '^content-type:'
file --mime-type file.css

Frequently asked questions

What is the MIME type for .css files?

text/css.

What Content-Type header should a .css file be served with?

Content-Type: text/css; charset=utf-8. As a text format, include the charset so browsers don't guess the encoding. It compresses well, so let the server apply gzip or Brotli.

Related types

Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options