Use the parts of normalize.css (or sanitize.css) you need from your browserslist
Installations
npm install postcss-normalize
Developer
csstools
Developer Guide
Module System
CommonJS, ESM
Min. Node Version
>= 18
Typescript Support
No
Node Version
20.17.0
NPM Version
10.8.3
Statistics
819 Stars
45 Commits
40 Forks
18 Watching
2 Branches
10 Contributors
Updated on 16 Nov 2024
Bundle Size
4.21 kB
Minified
1.84 kB
Minified + Gzipped
Languages
CSS (79.04%)
JavaScript (20.96%)
Total Downloads
Cumulative downloads
Total Downloads
706,205,739
Last day
-5.8%
530,929
Compared to previous day
Last week
1.8%
3,022,890
Compared to previous week
Last month
1.1%
12,894,907
Compared to previous month
Last year
-9.6%
160,359,580
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
2
Dev Dependencies
5
PostCSS Normalize
PostCSS Normalize lets you use the parts of normalize.css or sanitize.css that you need from your browserslist.
1@import "normalize.css";
1@import "sanitize.css";
PostCSS Normalize uses a non-opinionated version of normalize.css, but an opinionated version may also be used.
1@import "normalize.css/opinionated.css";
Examples
Here is a sample of what normalize.css looks like when the browserslist
is ie >= 9
:
1/** 2 * Add the correct display in IE 9-. 3 */ 4 5audio, 6video { 7 display: inline-block; 8} 9 10/** 11 * Remove the border on images inside links in IE 10-. 12 */ 13 14img { 15 border-style: none; 16}
And here is the same sample when the browserslist is ie >= 10
:
1/** 2 * Remove the border on images inside links in IE 10-. 3 */ 4 5img { 6 border-style: none; 7}
Usage
Add PostCSS Normalize to your project:
1npm install postcss-normalize --save-dev
Add a browserslist entry in package.json
:
1{ 2 "browserslist": "last 2 versions" 3}
Use PostCSS Normalize to process your CSS:
1const postcssNormalize = require('postcss-normalize') 2 3postcssNormalize.process(YOUR_CSS /*, processOptions, pluginOptions */)
Or use it as a PostCSS plugin:
1const postcss = require('postcss') 2const postcssNormalize = require('postcss-normalize') 3 4postcss([ 5 postcssNormalize(/* pluginOptions */) 6]).process(YOUR_CSS /*, processOptions */)
PostCSS Normalize runs in all Node environments, with special instructions for:
Node | PostCSS CLI | Webpack | Create React App | Gulp | Grunt |
---|
PostCSS Import Usage
PostCSS Normalize includes a postcssImport
function to configure
PostCSS Import and allow you to continue using the @import
syntax.
1const postcss = require('postcss') 2const postcssImport = require('postcss-import') 3const postcssNormalize = require('postcss-normalize') 4 5postcss([ 6 postcssImport( 7 postcssNormalize( 8 /* pluginOptions (for PostCSS Normalize) */ 9 ).postcssImport( 10 /* pluginOptions (for PostCSS Import) */ 11 ) 12 ) 13]) // now you can use @import "normalize.css", etc. again
Alternatively, use @import-normalize
or @import-sanitize
to avoid conflicts
with @import
transforms.
1@import-normalize;
1@import-normalize "normalize/opinionated.css";
1@import-sanitize;
Options
allowDuplicates
The allowDuplicates
option determines whether multiple, duplicate insertions
of CSS libraries are allowed. By default, duplicate libraries are omitted.
1postcssNormalize({ allowDuplicates: true })
forceImport
The forceImport
option defines CSS libraries that will be inserted at the
beginning of the CSS file. Unless overriden by allowDuplicates
, duplicate
CSS libraries would still be omitted.
1postcssNormalize({ forceImport: true })
Specific CSS libraries may be defined.
1postcssNormalize({
2 forceImport: 'sanitize.css'
3})
browsers
The browsers
option defines an override of the project’s browserslist for
PostCSS Normalize. This option should be avoided in leui of a browserslist
file.
1postcssNormalize({ browsers: 'last 2 versions' })
CSS Libraries
PostCSS Normalize can include normalize.css or sanitize.css and configure either with the following combinations:
1@import "normalize"; /* also, @import "normalize.css" */ 2@import "normalize/opinionated"; /* also, @import "normalize.css/opinionated.css", @import "normalize.css/*" */ 3@import "sanitize"; /* also, @import "sanitize.css" */ 4@import "sanitize/assets"; /* also, @import "sanitize.css/assets.css" */ 5@import "sanitize/forms"; /* also, @import "sanitize.css/forms.css" */ 6@import "sanitize/reduce-motion"; /* also, @import "sanitize.css/reduce-motion.css" */ 7@import "sanitize/system-ui"; /* also, @import "sanitize.css/system-ui.css" */ 8@import "sanitize/typography"; /* also, @import "sanitize.css/typography.css" */ 9@import "sanitize/ui-monospace"; /* also, @import "sanitize.css/ui-monospace.css" */ 10@import "sanitize/*"; /* also, @import "sanitize.css/*" (sanitize + all additions) */
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
9 commit(s) and 8 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: Creative Commons Zero v1.0 Universal: LICENSE.md:0
Reason
0 existing vulnerabilities detected
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/csstools/postcss-normalize/test.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/csstools/postcss-normalize/test.yml/main?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 1 out of 1 npmCommand dependencies pinned
Reason
Found 4/29 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
5.3
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More