Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis+ 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 š„š