Properti style.fontSize digunakan untuk menetapkan ukuran font untuk teks.
Sintaks:
obj.style.fontSize: value;
Nilainya:
- absolute-size:
xx-small
x-small
small
medium
(default)large
x-large
xx-large
- relative-size:
larger
smaller
- Length
inherit
Contoh:
<HTML>
<HEAD>
<TITLE>style.fontSize</TITLE>
<SCRIPT TYPE="text/javascript">
function changeSize()
{
document.getElementById("myp").style.fontSize = "70px";
}
</SCRIPT>
</HEAD>
<BODY>
<P ID="myp">Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum... Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum... Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum... Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum... Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum...Lorem ipsum...</P>
<BUTTON TYPE="button" ONCLICK="changeSize()">Change Size!</BUTTON>
</BODY>
</HTML>