Set the font of a <p> element: - Javascript CSS Style Property

Javascript examples for CSS Style Property:font

Description

Set the font of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" style="font:italic bold 30px Georgia,serif;">This is a paragraph.</p>

<button type="button" onclick="myFunction()">Return font</button>

<script>
function myFunction() {/*from   ww  w.  j a va  2  s  .  c om*/
    document.getElementById("myP").style.font = 'bold 10px';
}
</script>

</body>
</html>

Related Tutorials