├── .gitignore
├── .gitattributes
├── postcss.config.js
├── src
├── css
│ ├── clients
│ │ ├── android.css
│ │ ├── gmail.css
│ │ ├── apple.css
│ │ └── outlook.css
│ ├── index.css
│ └── generic.css
└── index.js
├── .editorconfig
├── .github
├── workflows
│ └── nodejs.yml
└── CONTRIBUTING.md
├── license
├── test
└── test.js
├── .stylelintrc.json
├── package.json
├── email-normalize.css
├── readme.md
├── deprecated.md
└── media
└── logo.svg
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto eol=lf
2 |
--------------------------------------------------------------------------------
/postcss.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | require('postcss-import'),
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/src/css/clients/android.css:
--------------------------------------------------------------------------------
1 | /* Center email on Android 4.4 */
2 |
3 | div[style*="margin: 16px 0"] {
4 | margin: 0 !important;
5 | }
6 |
--------------------------------------------------------------------------------
/src/css/index.css:
--------------------------------------------------------------------------------
1 | @import "generic.css";
2 |
3 | @import "clients/android.css";
4 | @import "clients/apple.css";
5 | @import "clients/gmail.css";
6 | @import "clients/outlook.css";
7 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | indent_style = space
7 | insert_final_newline = true
8 | trim_trailing_whitespace = true
9 |
10 | [*.{css,js}]
11 | indent_size = 2
12 |
--------------------------------------------------------------------------------
/src/css/clients/gmail.css:
--------------------------------------------------------------------------------
1 | /* Normalize links in Gmail */
2 |
3 | u + #body a {
4 | color: inherit;
5 | text-decoration: none;
6 | font-size: inherit;
7 | font-weight: inherit;
8 | line-height: inherit;
9 | }
10 |
11 | /* Hide the download button on large images */
12 |
13 | u ~ div img + div > div {
14 | display: none;
15 | }
16 |
--------------------------------------------------------------------------------
/src/css/clients/apple.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Normalize triggered links, such as dates or phone numbers,
3 | * in Apple Mail / iOS Mail
4 | */
5 |
6 | a[x-apple-data-detectors] {
7 | color: inherit !important;
8 | text-decoration: none !important;
9 | font-size: inherit !important;
10 | font-family: inherit !important;
11 | font-weight: inherit !important;
12 | line-height: inherit !important;
13 | }
14 |
--------------------------------------------------------------------------------
/src/css/clients/outlook.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Tables in Outlook on Windows
3 | *
4 | * `border-collapse` removes spaces between tables caused by border size
5 | * `mso-table-[l/r]space` ensures no left and right space is added
6 | * next to tables (Outlook specific CSS attributes).
7 | */
8 |
9 | table {
10 | border-collapse: collapse;
11 | mso-table-lspace: 0;
12 | mso-table-rspace: 0;
13 | }
14 |
15 | /* Fix color of links, including visited, in Outlook */
16 |
17 | span.MsoHyperlink,
18 | span.MsoHyperlinkFollowed {
19 | color: inherit !important;
20 | mso-style-priority: 99 !important;
21 | }
22 |
--------------------------------------------------------------------------------
/src/css/generic.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Reset body
3 | *
4 | * Apple Mail, iOS Mail plus many more have preset margin and padding for
5 | * the HTML
- this normalizes it so rendering is consistent.
6 | */
7 |
8 | body {
9 | margin: 0;
10 | padding: 0;
11 | }
12 |
13 | /*
14 | * Normalize headings
15 | *
16 | * Values used are browser CSS defaults.
17 | *
18 | * Samsung Mail: older versions reset the font-size on elements
19 | * Mail.ru: resets font-size on &
20 | * Outlook.com: resets margin on
21 | */
22 |
23 | h1 {
24 | margin: 0.67em 0;
25 | font-size: 2em;
26 | }
27 |
28 | h2 {
29 | margin: 0.83em 0;
30 | font-size: 1.5em;
31 | }
32 |
33 | /* `html[dir] h3` increases specificity, to override Outlook.com */
34 |
35 | h3,
36 | html[dir] h3 {
37 | margin: 1em 0;
38 | font-size: 1.17em;
39 | }
40 |
--------------------------------------------------------------------------------
/.github/workflows/nodejs.yml:
--------------------------------------------------------------------------------
1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3 |
4 | name: Node.js CI
5 |
6 | on:
7 | push:
8 | branches: [main]
9 | pull_request:
10 | branches: [main]
11 |
12 | jobs:
13 | build:
14 | runs-on: ubuntu-latest
15 |
16 | strategy:
17 | matrix:
18 | node-version: [12, 14, 15]
19 |
20 | steps:
21 | - uses: actions/checkout@v2
22 | - name: Use Node.js ${{ matrix.node-version }}
23 | uses: actions/setup-node@v1
24 | with:
25 | node-version: ${{ matrix.node-version }}
26 | - run: npm install
27 | - run: npm test
28 | env:
29 | CI: true
30 |
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) Jay Oram
4 | Copyright (c) Cosmin Popovici
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 |
8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9 |
10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | const test = require('ava')
2 | const data = require('../src')
3 |
4 | const allNodes = (obj, key, array) => {
5 | array = array || []
6 |
7 | if ('object' === typeof obj) {
8 | for (let k in obj) {
9 | if (k === key) {
10 | array.push(obj[k])
11 | } else {
12 | allNodes(obj[k], key, array)
13 | }
14 | }
15 | }
16 |
17 | return array
18 | }
19 |
20 | test('all rules contain css', t => {
21 | const cssValues = allNodes(data, 'css').every(item => item.length > 1)
22 |
23 | t.is(cssValues, true)
24 | })
25 |
26 | test('all rules contain a description', t => {
27 | const cssValues = allNodes(data, 'description').every(item => item.length > 1)
28 |
29 | t.is(cssValues, true)
30 | })
31 |
32 | test('deprecated rules contain valid timestamp', t => {
33 | allNodes(data, 'deprecated')
34 | .forEach(timestamp => t.not(new Date(timestamp), 'Invalid Date'))
35 | })
36 |
37 | test('`deprecated` is undefined by default', t => {
38 | t.is(data.android['4.4'][0].deprecated, undefined)
39 | })
40 |
41 | test('`can_inline` is undefined by default', t => {
42 | t.is(data.android['4.4'][0].can_inline, undefined)
43 | })
44 |
--------------------------------------------------------------------------------
/.stylelintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "rules": {
3 | "block-no-empty": true,
4 | "block-opening-brace-newline-after": "always",
5 | "block-opening-brace-space-before": "always",
6 | "color-hex-case": "upper",
7 | "color-hex-length": "long",
8 | "color-no-invalid-hex": true,
9 | "comment-no-empty": true,
10 | "comment-whitespace-inside": "always",
11 | "declaration-block-semicolon-newline-after": "always",
12 | "declaration-block-trailing-semicolon": "always",
13 | "declaration-colon-space-after": "always",
14 | "declaration-colon-space-before": "never",
15 | "declaration-empty-line-before": "never",
16 | "indentation": 2,
17 | "max-empty-lines": 1,
18 | "max-line-length": 80,
19 | "no-empty-first-line": true,
20 | "no-empty-source": true,
21 | "no-extra-semicolons": true,
22 | "no-invalid-double-slash-comments": true,
23 | "no-invalid-position-at-import-rule": true,
24 | "no-irregular-whitespace": true,
25 | "property-no-unknown": [
26 | true,
27 | {
28 | "ignoreProperties": ["/^mso-/"]
29 | }
30 | ],
31 | "rule-empty-line-before": "always",
32 | "string-no-newline": true,
33 | "string-quotes": "double",
34 | "unit-no-unknown": true,
35 | "value-list-comma-space-after": "always",
36 | "value-list-comma-space-before": "never"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@maizzle/email-normalize",
3 | "version": "1.0.0",
4 | "description": "CSS resets for default styles in email clients",
5 | "license": "MIT",
6 | "repository": "maizzle/email-normalize",
7 | "bugs": "https://github.com/maizzle/email-normalize/issues",
8 | "contributors": [
9 | {
10 | "name": "Jay Oram",
11 | "url": "https://github.com/JayOram"
12 | },
13 | {
14 | "name": "Cosmin Popovici",
15 | "url": "https://github.com/cossssmin"
16 | }
17 | ],
18 | "scripts": {
19 | "build": "npm run style && postcss src/css/index.css -o email-normalize.css",
20 | "style": "stylelint src/css/**/*.css",
21 | "test": "npm run style && ava",
22 | "release": "np"
23 | },
24 | "engines": {
25 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
26 | },
27 | "main": "src/index.js",
28 | "files": [
29 | "src",
30 | "email-normalize.css"
31 | ],
32 | "style": "email-normalize.css",
33 | "keywords": [
34 | "normalize",
35 | "css",
36 | "reset",
37 | "email",
38 | "html-emails",
39 | "style"
40 | ],
41 | "publishConfig": {
42 | "access": "public"
43 | },
44 | "devDependencies": {
45 | "ava": "^3.15.0",
46 | "np": "*",
47 | "postcss": "^8.3.5",
48 | "postcss-cli": "^8.3.1",
49 | "postcss-import": "^14.0.2",
50 | "stylelint": "^13.0.0"
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/email-normalize.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Reset body
3 | *
4 | * Apple Mail, iOS Mail plus many more have preset margin and padding for
5 | * the HTML - this normalizes it so rendering is consistent.
6 | */
7 |
8 | body {
9 | margin: 0;
10 | padding: 0;
11 | }
12 |
13 | /*
14 | * Normalize headings
15 | *
16 | * Values used are browser CSS defaults.
17 | *
18 | * Samsung Mail: older versions reset the font-size on elements
19 | * Mail.ru: resets font-size on