Skip to content

tomhodgins/stringify-css-stylesheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stringify-css-stylesheet

Convert a CSS stylesheet object to a string of text with JavaScript in the browser environment.

about

When working in the browser environment with HTML and XML, the DOM can be stringified into text using things like innerHTML, outerHTML, and XMLSerializer, but no equivalent functions exist for converting a CSS stylesheet found in CSSOM into a string. That's what this module provides, and it only works in the browser environment.

usage

This software is distributed as an ES module and should work in all modern browsers (including Chrome/Safari/Edge/Firefox).

<style>a { --b: c; }</style>

<script type=module>
  import stringifyStylesheet from 'https://unpkg.com/stringify-css-stylesheet/index.js'

  // Log the stringified CSSStyleRule object to the console
  console.log(
    stringifyStylesheet(document.styleSheets[0])
  )
</script>

About

Convert a CSSStyleSheet object to a string of text

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors