Home  >  Article  >  Web Front-end  >  How to write JS and CSS in the same file

How to write JS and CSS in the same file

不言
不言Original
2018-06-28 11:05:323562browse

This article mainly introduces the writing method of writing JS and CSS in the same file. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

We often Merge multiple CSS or multiple JS into one to save requests, but at least two are still required. I saw on the MSDN Blog that it is possible to combine JS and CSS in one file. How to do it? Using comments, take a look at the code first.

<!-- /* 
window.onload=function(){ 
document.getElementById("test2").innerHTML="传说中滴JS测试者。如果你看到我,那<strong>JS</strong>也生效了"; 
} 
<!-- */  
<!-- #test1,#test2{border:3px #000 solid;padding:5px;color:#123456;background-color:#ccc;} strong{color:red;}

When CSS is processed,