Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

inline-css

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inline-css

Inline css into an html file.

  • 2.6.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
201K
increased by2.14%
Maintainers
1
Weekly downloads
 
Created

What is inline-css?

The inline-css npm package is used to convert CSS styles into inline styles within HTML documents. This is particularly useful for email templates where inline styles are often required for proper rendering across different email clients.

What are inline-css's main functionalities?

Basic Inline CSS Conversion

This feature allows you to convert CSS styles defined in the <style> tag into inline styles within the HTML elements. The example demonstrates converting a simple HTML document with a <style> tag into one with inline styles.

const inlineCss = require('inline-css');
const html = '<html><head><style>h1 { color: red; }</style></head><body><h1>Hello, world!</h1></body></html>';
inlineCss(html, { url: ' ' }).then((result) => {
  console.log(result);
});

Handling External CSS

This feature allows you to handle external CSS files by specifying the base URL. The example demonstrates converting an HTML document that links to an external CSS file into one with inline styles.

const inlineCss = require('inline-css');
const html = '<html><head><link rel="stylesheet" href="styles.css"></head><body><h1>Hello, world!</h1></body></html>';
inlineCss(html, { url: 'http://example.com/' }).then((result) => {
  console.log(result);
});

Preserving Media Queries

This feature allows you to preserve media queries in the final HTML output. The example demonstrates converting an HTML document with media queries into one with inline styles while keeping the media queries intact.

const inlineCss = require('inline-css');
const html = '<html><head><style>@media (max-width: 600px) { h1 { color: blue; } }</style></head><body><h1>Hello, world!</h1></body></html>';
inlineCss(html, { url: ' ', preserveMediaQueries: true }).then((result) => {
  console.log(result);
});

Other packages similar to inline-css

Keywords

FAQs

Package last updated on 20 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc