# The “name” attribute is never allowed on the “style” element.

> Canonical HTML version: https://rocketvalidator.com/html-validation/the-name-attribute-is-never-allowed-on-the-style-element
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The `<style>` element has no `name` attribute: HTML defines `name` only on a few elements, such as form controls, `iframe`, `meta` and `slot`, and `<style>` isn't one of them.

The validator reports the same tag twice: the error "Attribute “name” not allowed on element “style” at this point." and this warning, which explains it. Removing the attribute clears both.

The attribute usually comes from a theme, plugin or script that prints a `<style>` block with a `name` as a label, so it can find the block again later, for example with `document.getElementsByName()` or a `style[name="..."]` selector. Browsers still apply the CSS, so nothing looks broken, but the markup is invalid.

Label the block with `id` instead. It's allowed on every element, and `document.getElementById()` finds it directly. If several blocks share a label, use a `data-*` attribute such as `data-name`, and update the selectors that read it. When the tag comes from a plugin you can't edit, report it to the plugin's author.

If the tag also has `type="text/css"`, you can drop that too. It's the default, and the validator flags it with a separate warning.

## Invalid example

```html
<style name="promo-banner">
  .promo { background: #fff3cd; }
</style>
<script>
  const css = document.getElementsByName("promo-banner")[0];
</script>
```

## Valid example

```html
<style id="promo-banner">
  .promo { background: #fff3cd; }
</style>
<script>
  const css = document.getElementById("promo-banner");
</script>
```
