# .css MIME Type: text/css

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

- MIME type: `text/css`
- Extensions: .css
- Content-Type header: `text/css; charset=utf-8`
- Compress in transit: yes

## 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](https://www.devkult.com/headers/x-content-type-options.md), browsers enforce the type strictly.

## Server configuration

### 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">
```

## FAQ

### 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

- [.html — text/html](https://www.devkult.com/mime/html.md)
- [.js — text/javascript](https://www.devkult.com/mime/js.md)
- [.woff2 — font/woff2](https://www.devkult.com/mime/woff2.md)

Open the interactive page: https://www.devkult.com/mime/css