📄 README.md

← 返回目录

Juice ![](https://i.imgur.com/jN8Ht.gif)

[![CI][github-ci-shield]][github-ci] !Downloads [![License][license-shield]][license]

Given HTML, Juice will inline your CSS properties into the style attribute.

Some projects using Juice →

How to use

Juice has a number of functions based on whether you want to process a file, HTML string, or a cheerio document, and whether you want Juice to automatically get remote stylesheets, scripts and image dataURIs to inline.

To inline HTML without getting remote resources, using default options:

import juice from 'juice';

const result = juice("

");

result will be:

Try out the web client version

What is this useful for?

- HTML emails. For CSS support in email clients see Can I Email.

|--------|-------|------------| | applyAttributesTableElements | true | Create attributes for styles in juice.styleToAttribute on elements set in juice.tableElements. | | applyHeightAttributes | true | Use any CSS pixel heights to create height attributes on elements set in juice.heightElements. | | applyStyleTags | true | Inline styles in

The data-embed attribute will be removed from the output HTML, but no inlining or style tag removal will take place:


Ignoring CSS with comments

You can use special CSS comments to prevent Juice from inlining entire CSS files, rules, or even just declarations.

#### Ignore entire file

Add a / juice ignore / comment on the first line in your CSS:

Hello World

The entire CSS will be ignored (as in, not inlined).

With removeStyleTags: true, the whole