+ 2
Embedding CSS in JavaScript
1. Is it possible to embed CSS in JavaScript? 2. If possible, What are its limitations, Proâs and Conâs? 3. Is it good practice? If not why is it not good practice? Wish you reply and show me example for these questions Itâs ok if you donât know answer to all but if you know answer to anyone and u reply, it would be really considered a huge help! Thank You đđ»đ€
4 Respostas
+ 4
well embedding css in js doesn't make too much sense,you cannot directly embed css in js,and when it is done it slows done your code.an example:
style=document.createElement("style");
document.append(style);
style.innerHTML="
body{
color:blue;
text- align:center;
} ";
+ 1
Like đłđŹBrains answer, yes its possible but is not good practice because make code more fragmented... In html you insert content, css for style and js for interactions but if you insert in js some css/html code or in html some css/js code you make code more caothics... You can do it only if necessary (in your case in necessary only in web page script injection) else dont mix they
+ 1
Oh ok I get it thanks @Brains đđđ»
+ 1
Ya sure Iâll do it only if necessary @KrOW
Thanks man, Cheers đ„đ