# stylelint-selector-tag-no-without-class

> Stylelint plugin to disallow certain tags without a qualifying classname in selectors

Latest version **4.1.0** (published 2026-04-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install stylelint-selector-tag-no-without-class
pnpm add stylelint-selector-tag-no-without-class
yarn add stylelint-selector-tag-no-without-class
bun add stylelint-selector-tag-no-without-class
```

## Health

**Score 55/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.1.0 |
| Published | 2026-04-22 |
| First published | 2018-03-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 2 |
| Unpacked size | 17.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 22 |
| Author | Moxio |
| Maintainers | aboks, dennisc, moxio-bot |
| Keywords | stylelint-plugin, stylelint, css |

## Links

- npm: https://www.npmjs.com/package/stylelint-selector-tag-no-without-class
- Repository: https://github.com/Moxio/stylelint-selector-tag-no-without-class
- Homepage: https://github.com/Moxio/stylelint-selector-tag-no-without-class#readme
- Issues: https://github.com/Moxio/stylelint-selector-tag-no-without-class/issues
- npm.io page: https://npm.io/package/stylelint-selector-tag-no-without-class

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.5
- [postcss-selector-parser](https://npm.io/package/postcss-selector-parser.md) ^7.1.1

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 4.1.0 (latest) — 2026-04-22
- 4.0.0 — 2026-04-16
- 3.0.1 — 2024-03-08
- 3.0.0 — 2024-02-14
- 2.0.6 — 2023-06-16
- 2.0.5 — 2021-11-30
- 2.0.4 — 2021-04-20
- 2.0.3 — 2020-02-24
- 2.0.2 — 2019-09-23
- 2.0.1 — 2019-07-24
- 2.0.0 — 2018-03-12
- 1.0.0 — 2018-03-07
- 0.1.0 — 2018-03-06

## README

[![Build Status](https://travis-ci.org/Moxio/stylelint-selector-tag-no-without-class.svg?branch=master)](https://travis-ci.org/Moxio/stylelint-selector-tag-no-without-class)
[![NPM version](https://img.shields.io/npm/v/stylelint-selector-tag-no-without-class.svg)](https://www.npmjs.com/package/stylelint-selector-tag-no-without-class)

stylelint-selector-tag-no-without-class
=======================================
A [stylelint](https://github.com/stylelint/stylelint) plugin to disallow certain tags without a class qualifier in selectors.

For example, if this rule is configured for (only) the `<div>` tag, the following patterns are considered violations:
```css
div {}
```
```css
.foo div {}
```
```css
div .foo {}
```
```css
div, .bar {}
```
```css
div:hover {}
```
The following patterns are not considered violations:
```css
div.foo {}  /* (tag is qualified with a class) */
```
```css
a {}        /* (rule not configured for '<a>' tag) */
```

Rationale
---------
According to the HTML specification, tags like `<div>` and `<span>` do no inherently represent anything. It would therefore be strange to attach styling to such a generic container, even within a given context. We believe that tags like `<div>` and `<span>` should only have meaning (and thus receive corresponding style rules) when they have a class as an additional qualifier.

Installation
------------
Install this package as a development dependency using NPM:
```
npm install --save-dev stylelint-selector-tag-no-without-class
```

Usage
-----
Add the plugin and the corresponding rule to the stylelint configuration file, and configure the tags that should not be used as a selector without a qualifying classname:
```js
// .stylelintrc
{
  "plugins": [
    "stylelint-selector-tag-no-without-class"
  ],
  "rules": {
    "plugin/selector-tag-no-without-class": ["div", "span"]
  }
}
```

Primary option
--------------
`array|string`: `["array", "of", "tags", "or", "/regexes/"]|"tag"|"/regex/"`

Specification of tags that should not occur without a class qualifier. If a string is surrounded with `"/"`, it is interpreted as a regular expression. For example, `"^/h\d+$/"` disallows using any section heading without a class qualifier.

Versioning
----------
This project adheres to [Semantic Versioning](http://semver.org/). A list of notable changes for each release can be found in the [changelog](CHANGELOG.md).

License
-------
This plugin is released under the MIT license.

---
_Source: https://npm.io/package/stylelint-selector-tag-no-without-class · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
