Because "{" and "}" conflict with "{" and "}" in CSS.
It seems that quotation marks cannot be used, and there is no specific test.
In this way, writing scripts in CSS is easy It is not flexible anymore, but if you want to write a complex script into CSS, how should you deal with it? This is a question. After testing, you can first define a function and then call it in expression. However, since it is used in CSS expression, therefore, can only be run in IE.
The following is an example, click on the code to run.
]
<script>
ex=function(){
if(document.getElementById("dg")!=null){
return document.getElemntById("dg").offsetWidth;
}else{
return 500;
}
}
</script>