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

> Canonical HTML version: https://rocketvalidator.com/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
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

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

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

## Valid example

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