We would like to know how to set font size.
<!DOCTYPE html>
<html>
<head>
</head><!-- w w w. j av a 2s . c o m-->
<body>
<p>txt1</p>
<p>txt2</p>
<p>txt3</p>
<p>txt4</p>
<script type='text/javascript'>
var p_var=10;
var s=document.getElementsByTagName('p');
for(i=0;i<s.length;i++)
{
s[i].setAttribute("style","font-size:"+p_var+"px");
}
</script>
</body>
</html>
The code above is rendered as follows: