
Pass Data from CSS to JavaScript with CSS Variables
3/31/20About 1 minCSSArticle(s)blogbram.uscss
Pass Data from CSS to JavaScript with CSS Variables êŽë š
CSS > Article(s)
Article(s)
Pass Data from CSS to JavaScript with CSS Variables
What happens when you combine the fact that part after the : for CSS Custom Properties doesnât need to be valid CSS with window.getComputedStyle()? You get a way of passing data â including Arrays, Objects, and even JSON â from CSS to JavaScript. Psst⊠Hey kid⊠Did you know you can pass data from your ⊠Continue reading âPass Data from CSS to JavaScript with CSS Variablesâ
What happens when you combine the fact that part after the : for CSS Custom Properties doesnât need to be valid CSS with window.getComputedStyle()? You get a way of passing data â including Arrays, Objects, and even JSON â from CSS to JavaScript.
Shaw from X (x.com)
Psst⊠Hey kidâŠ
Did you know you can pass data from your CSS to your JS with CSS variables⊠including JSON data?

See JSON in CSS Vars by shshaw on CodePen.
Pass Data from CSS to JavaScript with CSS Variables
What happens when you combine the fact that part after the : for CSS Custom Properties doesnât need to be valid CSS with window.getComputedStyle()? You get a way of passing data â including Arrays, Objects, and even JSON â from CSS to JavaScript. Psst⊠Hey kid⊠Did you know you can pass data from your ⊠Continue reading âPass Data from CSS to JavaScript with CSS Variablesâ