Skip to main content

text/css

text

The MIME type for CSS stylesheets. Browsers require stylesheets linked via <link rel='stylesheet'> to be served as text/css or they are blocked. RFC 2318 defines this type. Missing or incorrect Content-Type on CSS files is a common cause of broken styling in strict-mode browsers and Content Security Policy environments.

Details

text/css is defined by RFC 2318 and is required for browser stylesheet loading.

Browser enforcement: browsers will refuse to apply stylesheets served with the wrong MIME type. This is a security measure to prevent CSS injection via JSON or other responses incorrectly loaded as stylesheets.

Server configuration: ensure your web server maps .css → text/css. Common issue: nginx defaults not updated, serving CSS as application/octet-stream.

CSP interaction: if a Content-Security-Policy style-src directive is present, the stylesheet must also match that policy regardless of MIME type.

Common use

CSS stylesheets served to browsers

!

Security note

Never serve dynamic content (user data) as text/css. CSS can be used for data exfiltration via attribute selectors.

See Also