npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

css-text-selector

v1.0.2

Published

Helper to empower CSS to find elements by text content

Readme

CSS Text Selector

Helper to empower CSS to find elements by text content.

After runnning the script you can use this CSS to find elements by their inner text.

Examples:

p[data-textcontent*="banana"] {
  /* Style paragraphs that contain specific text */
}

a[data-textcontent="show more"],
a[data-textcontent="click here"] {
  /* Highlight inaccessible links */
}

Development

npm install css-text-selector
npm run dev

This will start a dev server at http://localhost:3010 with hot module replacement.

Using Both Versions in Dev

In the dev environment, you can test both versions:

ES Module Version (from source):

<script type="module">
  import enableCssTextSelector from '/src/main.js';
  enableCssTextSelector();
</script>

Regular Script Version (UMD - auto-built on first request):

<script src="/dist/css-text-selector.js"></script>
<script>
  enableCssTextSelector();
</script>

The UMD version is automatically built and served when first requested in dev mode.

Installation

npm

npm install css-text-selector

CDN (via unpkg)

<!-- Minified -->
<script src="https://unpkg.com/css-text-selector/dist/css-text-selector.min.js"></script>

<!-- Unminified -->
<script src="https://unpkg.com/css-text-selector/dist/css-text-selector.js"></script>

CDN (via jsDelivr)

<!-- Minified -->
<script src="https://cdn.jsdelivr.net/npm/css-text-selector/dist/css-text-selector.min.js"></script>

<!-- Unminified -->
<script src="https://cdn.jsdelivr.net/npm/css-text-selector/dist/css-text-selector.js"></script>

Usage

npm / ES Modules

ES Module import (recommended):

import enableCssTextSelector from 'css-text-selector';
enableCssTextSelector();

CommonJS require:

const enableCssTextSelector = require('css-text-selector');
enableCssTextSelector();

Direct import from dist:

// ES Module
import enableCssTextSelector from 'css-text-selector/dist/css-text-selector.module.js';

// Or minified
import enableCssTextSelector from 'css-text-selector/dist/css-text-selector.module.min.js';

Browser Script Tag

Via CDN (minified):

<script src="https://unpkg.com/css-text-selector/dist/css-text-selector.min.js"></script>
<script>
  enableCssTextSelector();
</script>

Local file:

<script src="./node_modules/css-text-selector/dist/css-text-selector.min.js"></script>
<script>
  enableCssTextSelector();
</script>

Browser ES Module

<script type="module">
  import enableCssTextSelector from 'https://unpkg.com/css-text-selector/dist/css-text-selector.module.min.js';
  enableCssTextSelector();
</script>

Build

npm run build

This will create four JS files in the dist/ directory (both minified and unminified versions):

UMD format (for script tags and CommonJS):

  • css-text-selector.js - Unminified version
  • css-text-selector.min.js - Minified version

ES module format:

  • css-text-selector.module.js - Unminified version
  • css-text-selector.module.min.js - Minified version

Preview Production Build

npm run preview