MIME Types

text/css

The MIME type for Cascading Style Sheets used to style HTML documents.

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

1

Common Use

External stylesheet files linked in HTML documents

2

Common Use

CSS framework files (Bootstrap, Tailwind)

3

Common Use

Inline <style> blocks in HTML

4

Common Use

CSS preprocessor output files

Examples

Server Configuration

Serve files with the text/css MIME type:

# Nginx
location ~ \.css$ {
  add_header Content-Type "text/css";
}

# Apache
AddType text/css .css
HTML Usage

Use 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:

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.