Skip to main content
HTML Validation

The only allowed value for the “type” attribute for the “style” element is “text/css” (with no parameters). (But the attribute is not needed and should be omitted altogether.)

About This HTML Issue

A <style> element's type attribute can only be text/css, and since that is already the default, the cleanest fix is to delete the attribute.

The validator reports this error for any other value: a made-up MIME type such as text/stylesheet, a bare css, a preprocessor type such as text/less or text/scss, text/css with a parameter (text/css; charset=utf-8), or an empty type="". The value text/css itself, in any letter case, only gets the milder warning that the attribute is unnecessary.

The error is more than cosmetic. The HTML standard tells browsers to skip a <style> block whose type is present and is neither empty nor text/css, so the rules inside may never apply and the page renders without them. Older templates and CMS themes often carry these values from the HTML 4 era, when type was required and not every author knew the right MIME type.

If the block holds Less or Sass for a client-side compiler, compile it to CSS at build time and serve plain CSS instead. A <style> element only ever holds CSS.

Invalid example

<head>
  <meta charset="utf-8">
  <title>Opening hours</title>
  <style type="text/stylesheet">
    .notice {
      color: #8a1c1c;
    }
  </style>
</head>

Valid example

<head>
  <meta charset="utf-8">
  <title>Opening hours</title>
  <style>
    .notice {
      color: #8a1c1c;
    }
  </style>
</head>

Find issues like this automatically

Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.

Help us improve our guides

Was this guide helpful?
🌍 Trusted by teams worldwide

Validate at scale.
Ship accessible websites, faster.

Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.

Scheduled Reports
API Access
Open Source Standards
€5 / week

1K Weekly

1,000 monthly checks. Cancel anytime.

Get 1K Weekly →

Join teams across 40+ countries