<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>style样式</title></head><body> <h2 id="con">I love JavaScript</h2> <p id="con1"> JavaScript使网页显示动态效果并实现与用户交互功能。</p> <script type="text/javascript"> var mychar= document.getElementById("con"); mychar.style.color="red"; mychar.style.backgroundColor="#ccc"; mychar.style.width="400px"; var mysum=document.getElementById("con1"); mysum.style.color="blue"; mysum.style.fontSize="25"; </script></body></html>
解决了,字体大小属性值要加“px”